无法通过USB调试应用程序;(Unable to debug application over USB; works with emulator)

系统教程 行业动态 更新时间:2024-06-14 16:59:47
无法通过USB调试应用程序;(Unable to debug application over USB; works with emulator)

Windows上的Android Studio - 成功完成Gradle同步和构建后,我无法在我的(root)Android Galaxy S3上启动我的应用程序并通过USB进行调试。 我的设备上启用了USB调试功能 。

我能够:

通过仿真器上的调试接口进行配置和调试

在Android DDMS窗口中查看我的USB设备:

通过adb手动配置,然后通过调试器连接,使用Android Studio中调试窗口中出现的相同命令:


Cd "C:\Program Files (x86)\Android\android-studio\sdk\platform-tools" adb -d shell su pm uninstall com.company.myapplication ls -all /data/app | grep myapplication pm install -r "/data/local/tmp/com.company.myapplication" am start -n "com.company.myapplication/com.company.myapplication.MapsActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

在手动配置(见上文)之后,我可以附加到我的设备上的运行进程,并进行调试(包括命中断点):

尝试启动USB调试时,从“选择设备”窗口中选择我的设备:

...之后我得到以下输出(并且在Android设备UI上没有活动):


Waiting for device. Target device: samsung-sgh_t999-6XXXXXX2 Uploading file local path: D:\Data\XXXXXX\Sandpit\XXXXXX\MyApplication\app\build\outputs\apk\app-debug.apk remote path: /data/local/tmp/com.company.myapplication Installing com.company.myapplication DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.company.myapplication"` Launching application: com.company.myapplication/com.company.myapplication.MapsActivity. DEVICE SHELL COMMAND: am start -D -n "com.company.myapplication/com.company.myapplication.MapsActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Waiting for process: com.company.myapplication

在上面的例子中,在使用adb shell检查文件后,我注意到pm install命令有效 - 即位置/data/local/tmp/com.company.myapplication有一个更新的文件(基于时间戳)。 但是, am start不起作用,如下.apk文件

我努力了:-

重新启动计算机 重启Android设备 重新安装Android Studio 运行应用程序(而不是调试应用程序):相同的结果,Android设备上没有应用程序安装 创建一个新的测试应用程序,以查看我的原始应用程序中是否存在Gradle或Manifest配置问题。 清洁项目 同时连接Media device (MTP)和Camera (PTP) 启用模拟位置 ( Settings -> Developer options -> Allow mock locations )

将android:debuggable="true"到Android Manifest XML ( <appRoot>\MyApplication\app\src\main\AndroidManifest.xml ),尽管IDE建议相反:

确保启用ADB集成:

切换手机上的ADB连接( Settings -> Developer Options -> USB Debugging check/uncheck/recheck, reconnect )

更新到S3的最新Samsung驱动程序 - 已下载,在Windows设备管理器中刷新:

重新启动ADB服务器,包括root用户,然后重新连接(并随后通过USB重新尝试从Android Studio调试):
C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb wait-for-device C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb devices List of devices attached 6XXXXXX2 device C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb root C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb kill-server C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb start-server * daemon not running. starting it now on port 5037 * * daemon started successfully * C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb wait-for-device C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb devices List of devices attached 6XXXXXX2 device C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>

版本: -

我有Android Studio v0.8.2,但作为我的测试工作的一部分已经降级到0.8.1,这也不起作用(同样的问题)。 手机是SGH-T999,Android版本4.1.2

操作系统是Windows 7 Enterprise SP1

我省略了什么? 我还应该尝试什么?

Android Studio on Windows - Following successful Gradle sync and build, I am unable to launch my application on my (rooted) Android Galaxy S3 and debug via USB. I have USB Debugging enabled on my device.

I am able to:

provision and debug via the debug interface on the emulator

see my USB device in the Android DDMS window:

manually provision via adb, then connect via the debugger, using the same commands that come out of the debug window in Android Studio:


Cd "C:\Program Files (x86)\Android\android-studio\sdk\platform-tools" adb -d shell su pm uninstall com.company.myapplication ls -all /data/app | grep myapplication pm install -r "/data/local/tmp/com.company.myapplication" am start -n "com.company.myapplication/com.company.myapplication.MapsActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

Following manual provisioning (see above), I can attach to the running process on my device, and debug (including hitting breakpoints):

Select my device from the "Choose Device" window when attempting to initiate USB debugging:

... following which I get the following output (and no activity on the Android device UI):


Waiting for device. Target device: samsung-sgh_t999-6XXXXXX2 Uploading file local path: D:\Data\XXXXXX\Sandpit\XXXXXX\MyApplication\app\build\outputs\apk\app-debug.apk remote path: /data/local/tmp/com.company.myapplication Installing com.company.myapplication DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.company.myapplication"` Launching application: com.company.myapplication/com.company.myapplication.MapsActivity. DEVICE SHELL COMMAND: am start -D -n "com.company.myapplication/com.company.myapplication.MapsActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Waiting for process: com.company.myapplication

In the case above, after checking files using the adb shell, I have noticed that the pm install command works -- i.e. there's an updated file (based on timestamp) in location /data/local/tmp/com.company.myapplication. However, the am start doesn't work, as the .apk file under

I have tried:-

Restarting the computer Restarting the Android device Reinstalling Android Studio Run app (rather than Debug app): same result, no app installation on Android device Creating a new test application to see whether it's a problem with Gradle or Manifest configuration problems in my original application. Cleaning the project Connecting as both a Media device (MTP), and also as Camera (PTP) Enabling mock locations (Settings -> Developer options -> Allow mock locations)

Adding android:debuggable="true" to the Android Manifest XML (<appRoot>\MyApplication\app\src\main\AndroidManifest.xml), despite IDE suggestion to the contrary:

Ensuring ADB Integration is enabled:

Toggling the ADB connection on the phone (Settings -> Developer Options -> USB Debugging check/uncheck/recheck, reconnect)

Updating to the latest Samsung drivers for the S3 - downloaded, refreshed in Windows Device Manager:

Restarting the ADB Server, including as root, then re-connecting (and subsequently re-attempting debugging from Android Studio over USB):
C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb wait-for-device C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb devices List of devices attached 6XXXXXX2 device C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb root C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb kill-server C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb start-server * daemon not running. starting it now on port 5037 * * daemon started successfully * C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb wait-for-device C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>adb devices List of devices attached 6XXXXXX2 device C:\Program Files (x86)\Android\android-studio\sdk\platform-tools>

Versions:-

I had Android Studio v0.8.2, but as part of my testing efforts have since downgraded to 0.8.1, which also doesn't work (same problem). Cell phone is SGH-T999, Android version 4.1.2

OS is Windows 7 Enterprise SP1

What have I omitted? What else should I try?

最满意答案

也许安装Universal ADB Driver会有所帮助。 ( 下载 )

Just to provide closure... I ended up dropping this device, and it wasn't worth repairing the screen, so this device no longer exists. My new device - also an S3 - works after being rooted.

更多推荐

本文发布于:2023-04-17 09:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/1dccabfab2666c456534dfa9a1e882d5.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   Unable   USB   debug   emulator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!