我有一个简单的android项目,它构建了APK OK但是我无法将其部署到我的设备上。目前我必须手动复制APK并安装它,这非常烦人。
我在非maven项目上启用了USB调试,因此与设备的实际连接应该没问题
当我运行mvn -e android:deploy -Dandroid.device=usb
时,我得到以下输出:
[INFO] Finished at: Sun Mar 20 16:31:29 GMT 2011
[INFO] Final Memory: 59M/541M
[INFO] ------------------------------------------------------------------------
C:\development\projects\AndroidSam_mavenbranch>mvn -e android:deploy -Dandroid.device=usb
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Android Plugin - samples
[INFO] task-segment: [android:deploy] (aggregator-style)
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/com/admob/android/ads/20101109-ANDROID-3312276cc1406347/ads-20101109-ANDROID-3312276cc14
06347.pom
[INFO] Unable to find resource 'com.admob.android:ads:pom:20101109-ANDROID-3312276cc1406347' in repository central (http://repo1.ma
ven.org/maven2)
[INFO] [android:deploy {execution: default-cli}]
[INFO] C:\development\tools\androidSDK\android-sdk-windows/tools/adb [-d, install, -r, C:\development\projects\AndroidSam_mavenbran
ch\target\AndroidSam.apk]
[INFO] 'C:\development\tools\androidSDK\android-sdk-windows\tools\adb' is not recognized as an internal or external command,
[INFO] operable program or batch file.
[ERROR]
[ERROR] 'C:\development\tools\androidSDK\android-sdk-windows\tools\adb' is not recognized as an internal or external command,operab
le program or batch file.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error deploying C:\development\projects\AndroidSam_mavenbranch\target\AndroidSam.apk to device.
Embedded error: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "C:\development\tools\androidSDK\android-sdk-windows\to
ols\adb -d install -r C:\development\projects\AndroidSam_mavenbranch\target\AndroidSam.apk", Result = 1
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error deploying C:\development\projects\AndroidSam_mavenbranch\target\Andro
idSam.apk to device.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error deploying C:\development\projects\AndroidSam_mavenbranch\target\An
droidSam.apk to device.
at com.jayway.maven.plugins.android.AbstractAndroidMojo.deployApk(AbstractAndroidMojo.java:425)
at com.jayway.maven.plugins.android.AbstractIntegrationtestMojo.deployBuiltApk(AbstractIntegrationtestMojo.java:101)
at com.jayway.maven.plugins.android.standalonemojos.DeployMojo.execute(DeployMojo.java:48)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "C:\dev
elopment\tools\androidSDK\android-sdk-windows\tools\adb -d install -r C:\development\projects\AndroidSam_mavenbranch\target\Android
Sam.apk", Result = 1
at com.jayway.maven.plugins.android.CommandExecutor$Factory$1.executeCommand(CommandExecutor.java:186)
at com.jayway.maven.plugins.android.CommandExecutor$Factory$1.executeCommand(CommandExecutor.java:158)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.deployApk(AbstractAndroidMojo.java:417)
... 21 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Sun Mar 20 16:31:50 GMT 2011
[INFO] Final Memory: 43M/555M
[INFO] ------------------------------------------------------------------------
这就是我的POM的样子:
<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.jameselsey</groupId>
<artifactId>AndroidSam</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Maven Android Plugin - samples</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.admob.android</groupId>
<artifactId>ads</artifactId>
<version>20101109-ANDROID-3312276cc1406347</version>
<!--<scope></scope>-->
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>maven-android-plugin</artifactId>
<version>2.6.0</version>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6)-->
<platform>8</platform>
</sdk>
<emulator>
<!-- the name of the avd device to use for starting the emulator-->
<avd>GoogleAPIs</avd>
</emulator>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<device>
</device>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<!-- version 2.3 defaults to java 1.5, so no further configuration needed-->
<version>2.3</version>
</plugin>
</plugins>
</build>
</project>
有什么想法吗?
答案 0 :(得分:7)
我注意到你使用的是maven-android-plugin(2.6.0)的旧版本。我们在版本2.8.1中添加了platform-tools/
的新Android SDK目录布局的自动支持。
请升级到最新版本。有关可用版本,请参阅更改日志:
http://code.google.com/p/maven-android-plugin/wiki/Changelog
谢谢,
雨果
答案 1 :(得分:0)
您可以使用adb进行安装 adb install {apk的路径}