Error type 3. Activity class {com.awesome_project/ com.awesome_project.MainActivity} does not exist in react native (Android device)

后端 未结 24 1544
甜味超标
甜味超标 2021-01-30 20:10

I\'ve created the project using the following command.

react-native init Awesome_Project

I\'ve started the packager using the following com

相关标签:
24条回答
  • 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

    0 讨论(0)
  • 2021-01-30 20:32

    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!

    0 讨论(0)
  • 2021-01-30 20:32

    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 讨论(0)
  • 2021-01-30 20:34

    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">
    
    0 讨论(0)
  • 2021-01-30 20:34

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

    0 讨论(0)
  • 2021-01-30 20:35

    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
    
    0 讨论(0)
提交回复
热议问题