gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:10:09 25 4
gpt4 key购买 nike

我目前正在尝试通过 eclipse 在我的设备上调试 android 应用程序。

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

adb devices
List of devices attached
0019cca27f2e6e device

还有 eclipse :

enter image description here

我可以在设备/模拟器上毫无问题地运行该应用程序。我只是执行 clean installandroid:deploy ,然后执行 android:run 并且工作得很好。但我还不知道如何调试它。

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

我已经阅读了这些 Material :

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

最佳答案

添加

android:debuggable="true"

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

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

关于java - 如何调试使用 maven 构建的 android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11345740/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com