我正在使用Maven和Eclipse构建一个Android应用程序,我在部署到Android后遇到了问题。我正在使用mvn clean install android:deploy来编译和部署我的应用程序但是虽然上传到手机后生成的apk没有任何错误我得到了一个奇怪的行为。
应用程序启动正常(它包含一些不同的活动),我可以去行动。 1行动。 2,从行动。采取行动。 3但是当我试图继续行动时。 3行动。 4该应用程序因“未找到课程”例外而停止。
我真的很绝望,因为很长一段时间试图猜测什么是无用的,但有一个奇怪的事情是,如果我在目标/类中查看相应的.class文件,导致错误就在那里! / p>
我正在使用Maven 3.1和android-maven-plugin,我的pom文件复制如下。我真的很绝望,因为我无法找到解决方案所以任何帮助将不胜感激。
提前谢谢!
d
http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.myApp.myApp 对myApp 1.0 APK 对myApp
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>4.1.1.4</platform.version>
<android.plugin.version>3.8.1</android.plugin.version>
<keystore.location>/home/myName/Documents/projects/MyApp/keystore/MyApp_keystore</keystore.location>
<keystore.password></keystore.password>
<keystore.keypass></keystore.keypass>
<keystore.alias>myapp</keystore.alias>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-android</artifactId>
<version>1.6.1-RC1</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}_unsigned</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<inherited>true</inherited>
<configuration>
<sign>
<debug>false</debug>
</sign>
<sdk>
<platform>19</platform>
</sdk>
<zipalign>
<skip>false</skip>
<verbose>true</verbose>
<inputApk>${project.build.directory}/${project.artifactId}_unsigned.apk</inputApk>
<outputApk>${project.build.directory}/${project.artifactId}.apk</outputApk>
</zipalign>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<executions>
<execution>
<id>zipalign</id>
<phase>verify</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
<goal>verify</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<removeExistingSignatures>true</removeExistingSignatures>
<archiveDirectory/>
<includes>
<include>${project.build.directory}/${project.artifactId}.apk</include>
</includes>
<keystore>${keystore.location}</keystore>
<alias>${keystore.alias}</alias>
<storepass>${keystore.password}</storepass>
<keypass>${keystore.keypass}</keypass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
答案 0 :(得分:0)
万一有人面临同样的问题,最后在一个绝望的一周寻找解决方案后,事实证明这是一个非常愚蠢和简单的事情。
有问题的类使用了android-support,因为在pom.xml中我错误地包含提供的android-support依赖项,这使得android支持jar不被包含在maven依赖项文件夹中,所以这就是问题,类是'找到它。
这里的问题是错误不明确,因为它抱怨缺少一个类而不是丢失的jar或类似的东西。它一直在我面前,但我没有看到它。
我希望它可以帮助有同样问题的人。