使用adb shell am启动Android Activity时提示“Bad component name”错误的排查求助
Hey there, let's break down why you're hitting that frustrating "Bad component name" error when trying to launch your Activity via adb.
The Root Cause
The am start -n command requires a full component name in the strict format:[APP_PACKAGE_NAME]/[FULL_ACTIVITY_CLASS_NAME]
Looking at your Manifest details:
- Your app's official package name is
com.telink.ble.mesh.demo(from the<manifest>tag'spackageattribute) - Your Activity's full class name is
com.telink.ble.mesh.ui.DeviceProvisionActivity(from the<activity>tag'snameattribute)
Your earlier attempts either omitted the package name entirely, or combined it with the Activity name in the wrong way (no / separator), which is why the system couldn't recognize the component.
Correct adb Command
Try running this command instead—it uses the proper component name format:
adb -s "R5CRC0HRRAW" shell am start -n com.telink.ble.mesh.demo/com.telink.ble.mesh.ui.DeviceProvisionActivity
How to Verify the Component
If you want to double-check that the component is properly registered, run this command to list all components for your app:
adb -s "R5CRC0HRRAW" shell dumpsys package com.telink.ble.mesh.demo | grep DeviceProvisionActivity
You should see a line referencing com.telink.ble.mesh.ui.DeviceProvisionActivity if the Activity is correctly set up in your Manifest.
Quick Side Note
Since your Activity doesn't have an <intent-filter> with a MAIN action, launching it via the explicit component name is the only valid approach here—this command should work once you use the correct format.
内容的提问来源于stack exchange,提问作者Enzo Abjean

