94

I've created the project using the following command.

react-native init Awesome_Project

I've started the packager using the following command.

react-native start

I've connected my Android mobile using USB drive.

I've opened another command prompt and run the following adb command to make sure that only one device is connected.

adb devices

I've started the application using the following command.

react-native run-android

I've been confronted with the following error.

open: Permission denied
open: Permission denied
Starting: Intent { com.awesome_project/.MainActivity }
Error type 3
Error: Activity class {com.awesome_project/ com.awesome_project.MainActivity} does not exist.
1
  • 1
    in my case i just uninstall application and reinstall using cd android && gradlew clean && cd .. && react-native run-android
    – abhi
    Commented Jan 5, 2018 at 11:07

30 Answers 30

147

Make sure android/app/build.gradle

defaultConfig {
        applicationId "WHATEVER_THIS_IS" 
}

needs to match android/app/src/main/java/com/app_name/MainActivity.java line one:

package WHATEVER_THIS_IS;

needs to match android/app/src/main/java/com/app_name/MainApplication.java line one:

package WHATEVER_THIS_IS;

needs to match android/app/src/main/AndroidManifest.xml line one:

package="WHATEVER_THIS_IS">
7
  • 1
    added android>app>src>main>java>com>app_name>MainApplication.java direction too. Commented Nov 3, 2016 at 13:46
  • 1
    If your Activity class {} does not exist you will lose on enhanced features like deep-linking. It's pretty important that the device know how to launch the app without you pressing the button. Just good developer practice...
    – parker
    Commented Dec 21, 2016 at 15:44
  • 55
    I've done checking all this, and didn't solve anything
    – TomSawyer
    Commented Aug 23, 2017 at 10:39
  • 10
    This didn't solve my problem either, but @Fran solution of adb uninstall WHATEVER_THIS_IS did solve it! Commented Oct 15, 2019 at 20:58
  • This worked, but failed a couple of times at the outset because I had a typo in one of the app ID locations specified or forgot to run gradelew clean between edits, an important step. For whatever reason our app needs a different applicationId in app/src/build.gradle in order to separate builds for Microsoft AppCenter Code push. Switching it to match the other files allowed me to run the build on a local emulator.
    – Joey T
    Commented Dec 19, 2019 at 23:20
119

I uninstalled the app from my device and was not able to see it in my Settings > Apps at all. The error finally went away after I fully uninstalled the app by doing:

adb uninstall com.appname
9
  • 2
    Thank you! I had a work profile (in additional to a personal profile) on my Android and had uninstalled it from one but not the other.
    – Luciano
    Commented Oct 6, 2018 at 21:03
  • Solved my problem!
    – szskdgi
    Commented Mar 3, 2019 at 9:11
  • Worked for me as well. Commented Sep 15, 2019 at 7:35
  • My god. Lucky I found this. Why is the error message so misleading?
    – Sharcoux
    Commented Mar 27, 2020 at 15:48
  • @Fran dude you are the saviour.. i owe you.. Thanks buddy.
    – saurabh
    Commented Jul 3, 2020 at 6:40
40

If you have appIdSuffix you should add it to the command for react native run command.

eg.   react-native run-android --appIdSuffix beta

Should add shortcut to package.json and run via npm.

...
"scripts": {
 ...
  "android-beta": "react-native run-android --appIdSuffix beta",
},

Then just run:

npm run android-beta
2
  • 4
    you saved me from a minor headache Commented May 25, 2018 at 10:02
  • just adding: where to find what suffix you need to add ... look for applicationIdSuffix in file build.gradle ... it could be defined in buildTypes or flavour like this: buildTypes { debug { applicationIdSuffix ".debug" ...
    – Babu
    Commented Mar 8, 2022 at 13:58
20

adb uninstall packageName Worked for me. for eg: adb uninstall com.abc

2
  • Just few days back I upvoted this and now had to come back here one more time. Really helpful. Commented Oct 26, 2020 at 19:18
  • what is the packageName? How can I find it?
    – Taha Ateş
    Commented May 21, 2022 at 12:18
14

In my case the app just doesn't open automatically, there's no other issue.

Just search for the app icon in your android device (look at location of all applications) and tap on it to open the app manually. The packager will begin to load the app as usual.

So this seems to be a bug here. Unfortunately I don't really know what's causing it.

4
  • 1
    Although you are correct in that the app doesn't launch automatically, you WANT the auto launching. Without this you lose enhanced features like deep-linking. See my answer above, your configuration is off somewhere.
    – parker
    Commented Dec 21, 2016 at 15:37
  • set path of sdk in environment variable , That's it !! Commented Apr 23, 2017 at 2:25
  • 3
    i had the same experience, the apk is intalled but the emulator just dosent start the app automatically Commented Apr 25, 2017 at 9:36
12

I had changed my application id from com.appName to com.companyName.appName, and I had made this update in android>app>build.gradle:

defaultConfig {
  applicationId "com.companyName.appName" // was previously "com.appName"
}

I also changed my file structure from android>app>src>main>java>com>appName to android>app>src>main>java>com>companyName>appName. This is when I got the error.

To fix the error, I simply did a project wide search (CMD-SHIFT-F in Atom) for com.appName, and replaced them all with com.companyName.appName. Problem solved!

1
  • thanks. I think that it cause by using Refactor feature with Android Studio. Maybe I had run rename or move somemthing... But it doesn't change relative to react-native.
    – ogelacinyc
    Commented Aug 7, 2017 at 6:37
9

try running adb command to install the apk (should provide more output) from android dir in your project: adb install app/build/outputs/apk/app-debug.apk

In my case was a insufficient storage case

facebook/react-native issue #2885

5

I ran into this issue after having a successful build installed on my phone, but long story short I had to uninstall it in order to do a fresh install. After uninstalling the app and trying to do a react-native run-android, I received this error.

Seems that 'uninstalling' an application on some devices only disables it in case you wish to undo the uninstall within a certain time frame. To remedy this, I went into Applications under settings and selected my app and completely uninstalled it. After that I was able to successfully build my app again. Hope this helps someone out.

5

You may have deleted/uninstalled your app, but when you check in your settings/apps, you can see that it's not totally uninstalled.

  • Go to Settings.
  • Go to Apps.
  • Select your app. (here, you can verify that your app is not uninstalled properly).
  • Open the overflow menu on the top right and select Uninstall for all users. Done. Try to install then launch your app again.

Source

1
  • It worked for me, somehow i had it installed for not the current user... Commented Mar 22, 2019 at 21:37
5

When working with react-native-config, I ran into this issue when using applicationIdSuffix with productFlavors.

adding --appIdSuffix=[YOUR_FLAVOR] to my react-native run-android commands did the job. e.g

...
    flavorDimensions "env"
    productFlavors {
        dev {
            resValue "string", "app_name", "[DEV] My App"
            applicationIdSuffix ".dev"
        }
        staging {
            resValue "string", "app_name", "[STG] My App"
            applicationIdSuffix ".staging"
        }
        prod {
            resValue "string", "app_name", "My App"
        }
    }
...
...
"scripts": {
    "android": "react-native run-android --variant=devDebug --appIdSuffix=dev",
    "android:staging": "react-native run-android --variant=stagingDebug --appIdSuffix=staging",
    "android:prod": "react-native run-android --variant=prodDebug",
    "android:staging:release": "react-native run-android --variant=stagingRelease --appIdSuffix=staging",
    "android:prod:release": "react-native run-android --variant=prodRelease",
},
...
1
  • Thank you! I've had the issue for long time and only with your method it solved
    – Dika
    Commented Apr 13, 2022 at 1:29
4

I had a similar issue.

BUILD SUCCESSFUL in 38s
27 actionable tasks: 27 executed
info Connecting to the development server...
info Starting the app on "a77c634"...
Starting: Intent { cmp=com.helloworld/.MainActivity }
Error type 3
Error: Activity class {com.helloworld/com.helloworld.MainActivity} does not exist.e

For me, my target device had multiple accounts, so before running the app for another ime, make sure you uninstall it from all accounts.

3

I had a slightly different take on the same issue.

I'm not using react, however I did run into this same issue.

I tried all of the solutions on this page and, oddly enough, each of them worked once. But the problem continued to come back.

In the end I found that doing:

  1. adb uninstall com.appname

  2. followed by a restart of the handset

Solved the issue every time since discovering.

Using a Samsung S8 and Android 3.4.1. No crazy libraries other than OKHttp. Running on a Mac.

2

For anyone else running into this issue where there are no solutions, if you've linked libraries, make sure that in the settings.gradle file located in ProjectName/android has your app in the include statement, like so: include ':ThirdPartyLibrary', ':app'. I forgot :app and it was build and installing the 3rd party library, but not the actual app, resulting in the problem.

2

This is happening if you have enabled build varaints in your app build.gradle file.

When react-native runs, it seems to prefix test or something to your application id which changes the package names in some files but leaves others the same. Your application cannot find .MainActivity because it actually does not exist in the new package namespace that was generated.

Here are some things to try to fix this issue:

  • Use FQDN in your Manifest file for the names of the application class and the activity class.
  • Replace your android cli file with this one. This is the file in /node_modules/react-native/local-cli/runAndroid

This should solve your issue.

2
  • I think you are right, but I don't know how to fix it. Android studio seems to automatically be adding a .debug to the end of my package name. The Build Variants tab has 'debug' and 'release' as options, but seemingly no way to remove them. Further, the information in the docs developer.android.com/studio/build/build-variants.html seems lacking in this regard.
    – AlecPerkey
    Commented Dec 6, 2017 at 3:38
  • I am currently working on a project where I will need to support build variants before deployment. I will endeavour to sort this issue out and update the answer with the solution.
    – prog_24
    Commented Dec 10, 2017 at 12:23
2

This issue occurred in my case when I uninstalled the app and tried installing with react-native run-android again.

Following worked for me:
1. Go to Application List from Settings Menu.
2. You will see your application in the list with a message on the left side "App not installed for this user".
3. Open that app in the settings, and then click on the top-right menu icon and select "Uninstall for all users". Hope it helps!

2

make sure your applicationid in gradle and package name is same

1
  • this was the problem for me, using hyphen char breaks the package :d
    – sekomer
    Commented Apr 5, 2023 at 9:38
1

Sometimes you get this error because you don't uninstall another previous version of the app, on the LG phones you must go to app's on settings and uninstall the app, this happens to me.

1

In my case.. none of the above solution worked. Then, i found the cause of it, i had previously installed application with same package name. I had uninstalled it from my phone, but as i have Oreo device.. it was installed in another user also. So, by uninstalling from all users.. solved my issue. It might not be helpful in your case.. but still this is my workaround.

1
  • A number of people already mentioned that they uninstalled the app first.
    – Jacksonkr
    Commented Oct 20, 2018 at 17:31
1

I solved it by installing the debug application manually on the mobile phone.

To do so, go to [Project_Path]\android\app\build\outputs\apk\debug\app-debug.apk

Copy this app-debug.apk to your mobile device.

Now, just install it normally in your mobile and you are good to go.

1

Huawei p20 lite. Tried to install app from downloads which would not install. Went back to run to install in android studio and got the error error 3 mainactivity does not exist. Had to delete user 'private space ' to solve the problem

1

cd android

and then

./gradlew uA

works for me.

0

Well, This happens when we uninstall apk from mobile manually.It shows MainActivity does not exist. Solution: Go to apps in setting and uninstall the instance of App for all users and run again using react-native run-android will resolve your issue

0

I tried all the answers posted above, no any outcome for my use case.

It got resolved finally by executing like this:

react-native run-android --variant=alphaDebug

if there are multiple flavours in the app, then we must mention variant through command line

0

In my case, I had the wrong package_name (client.client_info.android_client_info.package_name) in google-services.json (from Firebase). It had to match those four values as @parker mentioned.

0

This happened to me after changing my project package name. I tried some of the other answers here but nothing worked until I manually deleted the android/build directory, and re-ran react-native run-android forcing the app to be rebuilt from src. Turns out the build was cached including references to the old package name.

0

One that worked for me. Works in case if you accidentally uninstalled app from the connected device

  1. Delete apk: sudo rm -rf android/app/build/outputs/apk/debug
  2. Then: sudo npm run android
0

adb uninstall com.packagename. it worked for me.

0

This can be caused too if you're downloading a yarn based application and using npm install instead of yarn install to get your dependencies. So try to redownload the project and use the appropriate one.

0

for me removing the applicationId worked.

 defaultConfig {
     applicationId "com.companyName.xyz" // remove or comment out this line
    }
0

The adb uninstall command did it for me too. On Windows this is the command I had to execute:

%USERPROFILE%\appdata\Local\Android\sdk\platform-tools\adb uninstall org.company.topic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.