如何调试用maven构建的android应用程序

时间:2012-07-05 13:49:26

标签: java android maven android-intent maven-2

我正在尝试从eclipse调试我的设备上的android应用程序。

已添加设备我可以在控制台和日食中看到它。控制台(Windows):

adb devices
List of devices attached
0019cca27f2e6e  device

日食:

enter image description here

我可以在设备/模拟器上运行应用程序而不会出现任何问题。我只需clean installandroid:deploy,然后android:run,就像魅力一样。但我还无法弄清楚如何调试它。

但是当我实际在设备上运行应用程序(三星galaxy SII)时,我只能看到执行com.viber.voipcom.viber.voip:keepAliveReceiver的这两个进程即使我运行它也看不到我的应用程序。但是在模拟器/模拟器上,我可以看到我的应用正在运行。

我已经通过这个材料:

debugging an app startup with android maven plugin

How to start application in command line with Maven

http://code.google.com/p/maven-android-plugin/wiki/Debug

无法破解代码。甚至尝试用maven-exec-plugin通过调用下面的脚本来开始调试,这是pom中的插件:

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

debug_app.cmd的内容:

adb shell am start -D android.intent.action.MAIN -n my.package.name/.HelloAndroidActivity

当我执行此插件时,我收到以下错误:

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] pkg=android.intent.action.MAIN }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=android.intent.action.MAIN }

如果需要,这是我的manifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.SET_DEBUG_APP" >
</uses-permission>

<!-- <uses-permission android:name="android.permission.INTERNET" /> -->

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name" >
    <activity android:name=".HelloAndroidActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".DisplayMessageActivity" >
    </activity>
</application>

有没有人设法使用maven来调试设备来构建应用程序?

问题更新:

添加android:debuggable="true"我的应用程序出现在设备标签上,但我遇到了不同的问题(当我点击下面的绿色调试图标时)。

请参阅以下内容:

enter image description here

我发现此解决方法(解决方案除正确答案外)

http://code.google.com/p/android/issues/detail?id=9932

我接受了以下答案。可能也会有用:

https://groups.google.com/forum/?fromgroups#!topic/android-developers/DftP5gYcwYI

2 个答案:

答案 0 :(得分:3)

添加

android:debuggable="true"

在您的设备上显示并启用“USB调试”。

http://developer.android.com/tools/device.html#setting-up

答案 1 :(得分:2)

我这样做的方式是,

  1. 在AndroidManifest.xml文件中启用调试标志。
  2. 在设备上部署应用。您现在应该在eclipse调试管理器上看到应用程序的进程ID。
  3. 现在,在eclipse运行/配置菜单中配置远程java应用程序的运行/调试配置。
  4. 输入配置的所有详细信息。端口号将是图像附件的第3列。
  5. 在设备上启动应用程序“在eclipse中运行远程java应用程序配置”。
  6. 您的应用程序现在应该点击断点(如果有的话)。
相关问题