简体   繁体   English

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

[英]How to debug android application built with maven

I'm currently trying to debug android application on my device from eclipse. 我正在尝试从eclipse调试我的设备上的android应用程序。

Device has been added I can see it both in console and in eclipse. 设备已添加我可以在控制台和日食中看到它。 Console (Windows) : 控制台(Windows):

adb devices
List of devices attached
0019cca27f2e6e  device

And the eclipse : 和日食:

在此输入图像描述

I can run the app without any issues on both device/simulator. 我可以在设备/模拟器上运行应用程序而不会出现任何问题。 I just do clean install and android:deploy followed by android:run and works like a charm. 我只是做clean installandroid:deploy然后是android:run并且像魅力一样工作。 But I can't figure out yet how to debug it. 但我还无法弄清楚如何调试它。

But when I actually run the app on the device(Samsung galaxy SII) I can only see these two processes executing com.viber.voip and com.viber.voip:keepAliveReceiver I don't see my app even if I run it. 但是当我实际在设备上运行应用程序(三星galaxy SII)时,我只能看到执行com.viber.voipcom.viber.voip:keepAliveReceiver这两个进程com.viber.voip:keepAliveReceiver即使我运行它也看不到我的应用程序。 However on the simulator/emulator I can see my app running. 但是在模拟器/模拟器上,我可以看到我的应用正在运行。

I've gone trough this material: 我已经通过这种材料:

debugging an app startup with android maven plugin 使用android maven插件调试应用启动

How to start application in command line with Maven 如何使用Maven在命令行中启动应用程序

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

Can't break the code. 无法打破代码。 Even tried with maven-exec-plugin to start debugging by calling the script underneath, here is that plugin in pom : 甚至尝试使用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>

The contents of debug_app.cmd : debug_app.cmd的内容:

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

When I execute this plugin I get the following ERROR : 当我执行这个插件时,我得到以下错误:

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 }

Here is my manifest.xml if that is needed : 如果需要,这是我的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>

Has anyone manage to debug the device using maven to build the app? 有没有人设法使用maven来调试设备来构建应用程序?

Question update : 问题更新:

After adding the android:debuggable="true" my app appeared on the devices tab, but I encounter different issue(when I click on the green debug icon below). 添加android:debuggable="true"我的应用程序出现在设备选项卡上,但我遇到了不同的问题(当我点击下面的绿色调试图标时 )。

Please see below : 请看下面:

在此输入图像描述

I've found this workaround (solution in addition to the correct answer) : 我找到了这个解决方法(解决方案除了正确的答案)

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

And I've accepted answer below. 我接受了以下答案。 Might come useful as well : 可能也会有用:

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

Add

android:debuggable="true"

to manifest and turn on "USB Debugging" on your device. 在您的设备上显示并打开“USB Debugging”。

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

The way I do it is , 我这样做的方式是,

  1. Enable debug flag in AndroidManifest.xml file. 在AndroidManifest.xml文件中启用调试标志。
  2. Deploy the app on device. 在设备上部署应用程序。 You should now see the process id of your application on eclipse debug manager. 您现在应该在eclipse调试管理器上看到应用程序的进程ID。
  3. Now, configure a run/debug configuration of remote java application in eclipse run/config menu. 现在,在eclipse运行/配置菜单中配置远程java应用程序的运行/调试配置。
  4. Enter all details of the configuration. 输入配置的所有详细信息。 The port number will be 3rd column from you image attachment. 端口号将是图像附件的第3列。
  5. After starting the application on device "run the remote java application configuration" in eclipse. 在设备上启动应用程序“在eclipse中运行远程java应用程序配置”。
  6. You application should now hit the breakpoints if any. 您的应用程序现在应该点击断点(如果有的话)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM