mvn android:deploy无法正常运作(尽管成功确认) [英] mvn android:deploy not working (despite success confirmation)

查看:142
本文介绍了mvn android:deploy无法正常运作(尽管成功确认)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用android-maven-plugin 3.2.0并运行以下命令,以便在我的设备(Nexus One,Android 2.3.6)上安装并启动apk,这是唯一通过usb和对adb可见;也没有并行运行的仿真器.

I'm using the android-maven-plugin 3.2.0 and run the following in order to install and start the apk on my device (Nexus One, Android 2.3.6), which is the only one connected via usb and visible to adb; no emulator running in parallel either.

mvn install android:deploy android:run

下面是我的shell中的输出,看起来一切都很好,我什至收到一条消息说

Below is the output in my shell, which looks all good, and I even get a message saying

成功安装 /Users/myuser/Projects/MyCompany/com.mycompany.abc/target/com.mycompany.abc-1.0-SNAPSHOT.apk 到HT9CPP805008_HTC_NexusOne

Successfully installed /Users/myuser/Projects/MyCompany/com.mycompany.abc/target/com.mycompany.abc-1.0-SNAPSHOT.apk to HT9CPP805008_HTC_NexusOne

,但事实并非如此,apk未安装在我的设备上,无法在应用程序下找到. 我目前可以真正安装apk的唯一方法是通过

but it's not true, the apk is not installed on my device, can't be found under applications. The only way I can currently get the apk really installed is via a workaround, because android:deploy doesn't seem to work correctly. (adb itself works fine though, I can run any command (push, install, etc.) manually via adb and it also finds my devices without a problem. I'm on Mac OS X Lion with adb v1.0.29)

更新:

这是我刚刚发现的一个有趣的发现:android:deploy/run可以正常运行如果我之前已经在设备上安装了应用程序,然后运行maven,那么它将首先取消部署旧的apk,然后重新部署新的那一个.这行得通!但是-如果我以前完全没有在设备上安装该应用程序,或者在运行maven之前手动删除了该应用程序,那么它将无法正常工作.将<undeployBeforeDeploy>的值从true更改为false也没有任何区别.

Here's an interesting finding I just made: android:deploy/run works fine if I have the app already installed on my device before and then run maven, which would then undeploy the old apk firstly and then redeploy the new one. This works! But - if I don't have the app installed on my device at all before, or delete the app manually before running maven, it won't work. Changing the value of <undeployBeforeDeploy> from true to false doesn't make any difference here either.

以前有人遇到过这个问题吗?

Has anybody experienced this problem before?

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.mycompany:com.mycompany.abc:apk:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:exec-maven-plugin is missing. @ line 85, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building com.mycompany.abc 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- android-maven-plugin:3.2.0:deploy (default-cli) @ com.mycompany.abc ---
[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 set to usb
[INFO] Device HT9CPP805008_HTC_NexusOne found.
[INFO] Successfully installed /Users/myuser/Projects/MyCompany/com.mycompany.abc/target/com.mycompany.abc-1.0-SNAPSHOT.apk to HT9CPP805008_HTC_NexusOne
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.334s
[INFO] Finished at: Sat Jun 30 01:23:01 CST 2012
[INFO] Final Memory: 12M/126M
[INFO] ------------------------------------------------------------------------

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>
  <groupId>com.mycompanyany</groupId>
  <artifactId>com.mycompany.abc</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>apk</packaging>
  <name>com.mycompany.abc</name>

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

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <!-- Simply read properties from file -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0-alpha-2</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>android.properties</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                    <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                    <resourceDirectory>${project.basedir}/res</resourceDirectory>
                    <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                    <sdk>
                        <platform>11</platform>
                    </sdk>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>false</undeployBeforeDeploy>
                    <!--<sign><debug>false</debug></sign>-->
                    <device>usb</device>
                </configuration>
                <extensions>true</extensions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>exec-maven-plugin</artifactId>
                <groupId>org.codehaus.mojo</groupId>
                <configuration>
                    <executable>${basedir}/scripts/run_app.sh</executable>
                </configuration>
            </plugin>

        </plugins>
    </build>   

</project>

推荐答案

我正在使用maven插件正常工作(Linux和Galaxy Nexus),并且工作正常.

I'm working with maven plugin with no problem (Linux and Galaxy Nexus) and works fine.

尝试一下:

mvn clean install android:deploy android:run -Dandroid.device=usb

这是我的pom:

http://pastebin.com/tzuFyjSx

希望这对您有帮助

这篇关于mvn android:deploy无法正常运作(尽管成功确认)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆