0

I'm trying to launch an activity with adb shell am but i always had the error Bad component name.

 C:\Users\EnzoAbjean\Documents\Automatisation\TelinkSH-Enzo\qa-automatisation-tool>adb -s "R5CRC0HRRAW" shell am start -n com.telink.ble.mesh.ui.DeviceProvisionActivity

Exception occurred while executing 'start':
java.lang.IllegalArgumentException: Bad component name: com.telink.ble.mesh.ui.DeviceProvisionActivity

And this is my Manifest:

 <?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         package="com.telink.ble.mesh.demo">
      <application
             android:name="com.telink.ble.mesh.LightingApplication"
            android:allowBackup="true"
             android:icon="@mipmap/ic_launcher"
             android:label="@string/app_name"
             android:requestLegacyExternalStorage="true"
             android:supportsRtl="true"
             android:theme="@style/AppTheme"
             tools:ignore="GoogleAppIndexingWarning">
       <activity
                android:name="com.telink.ble.mesh.ui.DeviceProvisionActivity"
                 android:screenOrientation="portrait"
                 android:windowSoftInputMode="stateAlwaysHidden"
                 tools:ignore="LockedOrientationActivity" />
 

I don't really know how it doesn't worked. I tried to put the package name "com.telink.ble.mesh.demo" before but nothing.

  • i get a new error: " C:\Users\EnzoAbjean\Documents\Automatisation\TelinkSH-Enzo\qa-automatisation-tool>adb -s "R5CRC0HRRAW" shell am start -n com.telink.ble.mesh.ui/.DeviceProvisionActivity Starting: Intent { cmp=com.telink.ble.mesh.ui/.DeviceProvisionActivity } Error type 3 Error: Activity class {com.telink.ble.mesh.ui/com.telink.ble.mesh.ui.DeviceProvisionActivity} does not exist. " . But this class exist – Enzo Abjean Aug 19 '22 at 15:27
  • Sorry, I missed the info, the package name is `com.telink.ble.mesh.demo` so you have to start `am start -n com.telink.ble.mesh.demo/com.telink.ble.mesh.ui.DeviceProvisionActivity` – Robert Aug 19 '22 at 15:28
  • Does this answer your question? [How to start an application using Android ADB tools](https://stackoverflow.com/questions/4567904/how-to-start-an-application-using-android-adb-tools) – Robert Aug 19 '22 at 15:29
  • i got exactly the same error "Activity does not exist". Thanks for the link it will be useful for the intents. – Enzo Abjean Aug 19 '22 at 15:34
  • I tried with others activity in my application but got the same result. – Enzo Abjean Aug 19 '22 at 15:40

2 Answers2

0

Add exported and intent filter:

   <activity
            android:name="com.telink.ble.mesh.ui.DeviceProvisionActivity"
             android:screenOrientation="portrait"
             android:windowSoftInputMode="stateAlwaysHidden"
             tools:ignore="LockedOrientationActivity"
             android:exported="true">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>

    </activity>
             

then you should be able to launch with

am start -n com.telink.ble.mesh.demo/com.telink.ble.mesh.ui.DeviceProvisionActivity

as @Robert mentioned in the comments.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • ok thanks, i will try on monday i left my pc at work – Enzo Abjean Aug 20 '22 at 08:15
  • I try but the app says `"Error: Activity class {com.telink.ble.mesh.demo/com.telink.ble.mesh.ui.DeviceProvisionActivity} does not exist."` Is it maybe because i have a path for the application "com.telink.ble.mesh.LightningApplication"? As you can see above? – Enzo Abjean Aug 22 '22 at 06:48
0
android {
compileSdkVersion 29
buildToolsVersion = '28.0.3'

defaultConfig {
    applicationId "com.telink.ble.smart.home"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 3
    versionName "1.0.2"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Now my command line is adb -s "R5CRC0HRRAW" shell am start -n com.telink.ble.smart.home/com.telink.ble.mesh.ui.DeviceProvisionActivity

I looked my build.gradle and found a new path in the defaultConfig : "com.telink.ble.smart.home" and tried this path, so it worked. In my manifest I had to add an export for my activity. Thanks for your answers @Robert and @Diego Torres Milano.

ant_dev
  • 653
  • 8
  • 16