【问题标题】:How to debug android application built with maven如何调试使用maven构建的android应用程序
【发布时间】:2012-07-05 22:34:42
【问题描述】:

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

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

adb devices
List of devices attached
0019cca27f2e6e  device

还有日食:

我可以在两个设备/模拟器上运行该应用程序而不会出现任何问题。我只是做clean installandroid:deploy,然后是android:run,就像一个魅力。但我还不知道如何调试它。

但是当我实际在设备上运行应用程序(Samsung 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" 后,我的应用出现在设备选项卡上,但我遇到了不同的问题(当我点击下面的绿色调试图标时)。

请看下面:

我找到了这个解决方法(除了正确答案之外的解决方案)

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

我已经接受了下面的答案。也可能有用:

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

【问题讨论】:

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


    【解决方案1】:

    添加

    android:debuggable="true"
    

    在您的设备上显示并打开“USB 调试”。

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

    【讨论】:

      【解决方案2】:

      我的做法是,

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

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-11
      • 1970-01-01
      • 2013-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多