我有一个android库项目。我创造了一个罐子。现在我将jar复制到android应用程序中的libs文件夹,并使用eclipse和ant构建apk。 apk文件工作,但当我尝试使用maven构建apk文件无法正常工作。我有很长一段时间这个问题。 如果我在pom文件中犯了任何错误,你能纠正吗?
android应用程序的pom文件:
<?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>
<groupId>com.project.servicefoundation</groupId>
<artifactId>projectservicefoundation</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>projectserviceFoundation</name>
<dependencies>
<dependency>
<groupId>com.project.servicefoundation</groupId>
<artifactId>androidsdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.3</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<executions>
<execution>
<id>androidsdktests</id>
<phase>test</phase>
<goals>
<goal>
emulator-start
</goal>
<goal>
internal-integration-test
</goal>
</goals>
</execution>
</executions>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6) -->
<platform>19</platform>
</sdk>
<emulator>
<avd>mydevice</avd>
<!-- Wait for emulator starting (3 minutes) -->
<wait>180000</wait>
<options>-no-skin</options>
</emulator>
</configuration>
</plugin>
</plugins>
</build>
</project>
android库项目的pom文件
<?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>
<groupId>com.project.servicefoundation</groupId>
<artifactId>androidsdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AndroidSDK</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
android库项目的名称是androidsdk
。
答案 0 :(得分:0)
您已将androidsdk
的依赖关系声明为provided
,这意味着它不会包含在您的apk中(这解释了为什么它不起作用):
<dependency>
<groupId>com.project.servicefoundation</groupId>
<artifactId>androidsdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
只需删除<scope>provided</scope>
即可。