Search code examples
androidadb

error "bad component name" when launching android app with adb shell am start


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.


Solution

  • 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.