Search code examples
androidadb

starting an app using adb command error type 3


I have the following command

 adb -s 077743323A102985 shell am start -n com.instagram.android/.MainActivity

i am trying to start the instagram app via command line, but why does it gives me this error:

Starting: Intent { cmp=com.instagram.android/.MainActivity }
Error type 3
Error: Activity class {com.instagram.android/com.instagram.android.MainActivity} does not exist.

the app is installed and the package name is com.instagram.android


Solution

  • You should try to use LauncherActivity instead of MainActivity. The package name of the LauncherActivity is also a little bit different.

    To sum up, the following command will start Instagram app from the terminal:

    adb -s 077743323A102985 shell am start -n com.instagram.android/com.instagram.mainactivity.LauncherActivity
    

    In order to know which Activity to use to start an app you can follow these steps:

    1. get the apk of the app
    2. extract the AndroidManifest.xml file
    3. search for <action android:name="android.intent.action.MAIN"/> and <category android:name="android.intent.category.LAUNCHER"/> intent filters
    4. get the activity by looking at the android:targetActivity attribute

    You can apply these steps to all apps not only Instagram.