2

我做了一个基本的Android项目。我用 AVD 在 Eclipse 中运行它,一切都很好。它运行的应用程序。但是当我尝试时:mvn android:deploy一切似乎都很好,但是 AVD 说:Unfortunately App has stopped

mvn 干净安装

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SakebuApp 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ SakebuApp ---
[INFO] Deleting C:\Workspace\SakebuApp\target
[INFO] 
[INFO] --- android-maven-plugin:3.2.0:generate-sources (default-generate-sources) @ SakebuApp ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] C:\Program Files (x86)\Android\android-sdk\platform-tools\aapt.exe [package, -m, -J, C:\Workspace\SakebuApp\target\generated-sources\r, -M, C:\Workspace\SakebuApp\AndroidManifest.xml, -S, C:\Workspace\SakebuApp\res, --auto-add-overlay, -A, C:\Workspace\SakebuApp\assets, -I, C:\Program Files (x86)\Android\android-sdk\platforms\android-15\android.jar]
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ SakebuApp ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Workspace\SakebuApp\src\main\resources
[INFO] skip non existing resourceDirectory C:\Workspace\SakebuApp\target\generated-sources\extracted-dependencies\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ SakebuApp ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Workspace\SakebuApp\target\classes
[INFO] 
[INFO] --- android-maven-plugin:3.2.0:proguard (default-proguard) @ SakebuApp ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ SakebuApp ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Workspace\SakebuApp\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ SakebuApp ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12:test (default-test) @ SakebuApp ---
[INFO] No tests to run.
[INFO] Surefire report directory: C:\Workspace\SakebuApp\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- android-maven-plugin:3.2.0:emma (default-emma) @ SakebuApp ---
[INFO] 
[INFO] --- android-maven-plugin:3.2.0:dex (default-dex) @ SakebuApp ---
[INFO] C:\Program Files\Java\jdk1.6.0_22\jre\bin\java [-Xmx1024M, -jar, C:\Program Files (x86)\Android\android-sdk\platform-tools\lib\dx.jar, --dex, --output=C:\Workspace\SakebuApp\target\classes.dex, C:\Workspace\SakebuApp\target\classes]
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ SakebuApp ---
[INFO] Building jar: C:\Workspace\SakebuApp\target\SakebuApp.jar
[INFO] 
[INFO] --- android-maven-plugin:3.2.0:apk (default-apk) @ SakebuApp ---
[INFO] Copying local assets files to combined assets directory.
[INFO] C:\Program Files (x86)\Android\android-sdk\platform-tools\aapt.exe [package, -f, -M, C:\Workspace\SakebuApp\AndroidManifest.xml, -S, C:\Workspace\SakebuApp\res, --auto-add-overlay, -A, C:\Workspace\SakebuApp\target\generated-sources\combined-assets\assets, -I, C:\Program Files (x86)\Android\android-sdk\platforms\android-15\android.jar, -F, C:\Workspace\SakebuApp\target\SakebuApp.ap_]
[INFO] 
[INFO] --- android-maven-plugin:3.2.0:internal-pre-integration-test (default-internal-pre-integration-test) @ SakebuApp ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO] 
[INFO] --- android-maven-plugin:3.2.0:internal-integration-test (default-internal-integration-test) @ SakebuApp ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO] 
[INFO] --- maven-source-plugin:2.1.2:jar-no-fork (attach-sources) @ SakebuApp ---
[INFO] Building jar: C:\Workspace\SakebuApp\target\SakebuApp-sources.jar
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ SakebuApp ---
[INFO] Installing C:\Workspace\SakebuApp\target\SakebuApp.apk to C:\Users\HP\.m2\repository\com\sakebu\android\SakebuApp\1.0.0-SNAPSHOT\SakebuApp-1.0.0-SNAPSHOT.apk
[INFO] Installing C:\Workspace\SakebuApp\pom.xml to C:\Users\HP\.m2\repository\com\sakebu\android\SakebuApp\1.0.0-SNAPSHOT\SakebuApp-1.0.0-SNAPSHOT.pom
[INFO] Installing C:\Workspace\SakebuApp\target\SakebuApp.jar to C:\Users\HP\.m2\repository\com\sakebu\android\SakebuApp\1.0.0-SNAPSHOT\SakebuApp-1.0.0-SNAPSHOT.jar
[INFO] Installing C:\Workspace\SakebuApp\target\SakebuApp-sources.jar to C:\Users\HP\.m2\repository\com\sakebu\android\SakebuApp\1.0.0-SNAPSHOT\SakebuApp-1.0.0-SNAPSHOT-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.910s
[INFO] Finished at: Fri Jun 15 02:39:34 CEST 2012
[INFO] Final Memory: 20M/152M
[INFO] ------------------------------------------------------------------------

mvn 安卓:部署

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SakebuApp 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- android-maven-plugin:3.2.0:deploy (default-cli) @ SakebuApp ---
[INFO] C:\Program Files (x86)\Android\android-sdk\platform-tools\aapt.exe [dump, xmltree, C:\Workspace\SakebuApp\target\SakebuApp.apk, AndroidManifest.xml]
N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    A: android:versionCode(0x0101021b)=(type 0x10)0x1
    A: android:versionName(0x0101021c)="1.0" (Raw: "1.0")
    A: package="com.sakebu.android" (Raw: "com.sakebu.android")
    E: uses-sdk (line=7)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0xf
    E: application (line=9)
      A: android:label(0x01010001)=@0x7f040001
      A: android:icon(0x01010002)=@0x7f020000
      E: activity (line=12)
        A: android:label(0x01010001)=@0x7f040001
        A: android:name(0x01010003)=".SakebuAppActivity" (Raw: ".SakebuAppActivity")
        E: intent-filter (line=15)
          E: action (line=16)
            A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
          E: category (line=18)
            A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
[INFO] Waiting for initial device list from the Android Debug Bridge
[INFO] Found 1 devices connected with the Android Debug Bridge
[INFO] android.device parameter not set, using all attached devices
[INFO] Successfully uninstalled com.sakebu.android from emulator-5554_sakebuEM_unknown_sdk
[INFO] Found 1 devices connected with the Android Debug Bridge
[INFO] android.device parameter not set, using all attached devices
[INFO] Successfully installed C:\Workspace\SakebuApp\target\SakebuApp.apk to emulator-5554_sakebuEM_unknown_sdk
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.919s
[INFO] Finished at: Fri Jun 15 02:42:38 CEST 2012
[INFO] Final Memory: 11M/111M
[INFO] ------------------------------------------------------------------------

pom.xml

<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.sakebu.android</groupId>
    <artifactId>SakebuApp</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>SakebuApp</name>

    <dependencies>

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

    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <sdk>
                        <platform>15</platform>
                    </sdk>
                    <emulator>
                        <avd>sakebuEM</avd>
                    </emulator>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>

单击图标应用程序时的输出: Unfortunately App has stopped

当我运行 mvn android:deploy 时输出 Dalvik

06-15 08:53:39.025: D/AndroidRuntime(2173): Shutting down VM
06-15 08:53:39.025: W/dalvikvm(2173): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
06-15 08:53:39.055: E/AndroidRuntime(2173): FATAL EXCEPTION: main
06-15 08:53:39.055: E/AndroidRuntime(2173): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sakebu.android/com.sakebu.android.SakebuAppActivity}: java.lang.ClassNotFoundException: com.sakebu.android.SakebuAppActivity
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.os.Looper.loop(Looper.java:137)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.app.ActivityThread.main(ActivityThread.java:4424)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at java.lang.reflect.Method.invokeNative(Native Method)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at java.lang.reflect.Method.invoke(Method.java:511)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at dalvik.system.NativeStart.main(Native Method)
06-15 08:53:39.055: E/AndroidRuntime(2173): Caused by: java.lang.ClassNotFoundException: com.sakebu.android.SakebuAppActivity
06-15 08:53:39.055: E/AndroidRuntime(2173):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
06-15 08:53:39.055: E/AndroidRuntime(2173):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
06-15 08:53:39.055: E/AndroidRuntime(2173):     ... 11 more
06-15 08:53:39.265: I/dalvikvm(2173): threadid=3: reacting to signal 3
06-15 08:53:39.285: I/dalvikvm(2173): Wrote stack traces to '/data/anr/traces.txt'
06-15 08:53:39.705: I/dalvikvm(2173): threadid=3: reacting to signal 3
06-15 08:53:39.775: I/dalvikvm(2173): Wrote stack traces to '/data/anr/traces.txt'
4

1 回答 1

0

我创建了一个新的 maven android 项目。我认为问题是不正确的原型。我在新项目中遵循了以下步骤:m2Eclipse 集成,但您必须将 android-maven-plugin 更新到 3.2.0 版,否则无法正常工作。

于 2012-06-16T10:51:12.610 回答