gpt4 book ai didi

android - 使用Maven apklib时出现编译错误

转载 作者:行者123 更新时间:2023-12-02 10:55:06 26 4
gpt4 key购买 nike

我创建一个库项目,并将packing作为apklib。在应用程序中,我添加了功能:

<dependency>
<groupId>com.ati</groupId>
<artifactId>common-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>apklib</type>
</dependency>

我在我的应用程序项目中使用lib: com.ati.common_lib.Test.demo();,并使用 mvn clean install。有效!但是,如果我使用 import com.ati.common_lib;Test.demo();mvn clean build,则会引发错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project soci-news: Compilation failure: Compilation failure:
[ERROR] /Data/Work/workspace/soci-parent/soci-news/src/main/java/com/ati/soci_news/HelloAndroidActivity.java:[9,15] cannot find symbol
[ERROR] symbol : class common_lib
[ERROR] location: package com.ati
[ERROR] /Data/Work/workspace/soci-parent/soci-news/src/main/java/com/ati/soci_news/HelloAndroidActivity.java:[23,9] cannot find symbol
[ERROR] symbol : variable Test
[ERROR] location: class com.ati.soci_news.HelloAndroidActivity
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :soci-news

我在M2E-Android中使用Maven 3.0.5,Eclipse“开普勒版本”。我由m2e-android创建的库和应用程序。我在这里做错了什么?

更新

我的 parent pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ati</groupId>
<artifactId>soci-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Soci project parent</name>

<modules>
<module>common-lib</module>
<module>soci-news</module>
</modules>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<sdk>
<platform>8</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

我的图书馆pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.ati</groupId>
<artifactId>soci-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<groupId>com.ati</groupId>
<artifactId>common-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apklib</packaging>
<name>common lib for ati android application</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version> 2.2.1
</platform.version>
<android.plugin.version>3.6.1</android.plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

我的应用程序的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ati</groupId>
<artifactId>soci-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.ati</groupId>
<artifactId>soci-news</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>soci-news</name>

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.ati</groupId>
<artifactId>common-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>apklib</type>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

最佳答案

您的导入已损坏。
com.ati.common-lib是程序包,但您确实想导入该程序包的内容,所有内容都导入com.ati.common-lib.*,仅Test类导入com.ati.common-lib.Test

关于android - 使用Maven apklib时出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18605244/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com