Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Activity class ... does not exist #14952

Closed
theobouwman opened this issue Jul 11, 2017 · 17 comments
Closed

Error: Activity class ... does not exist #14952

theobouwman opened this issue Jul 11, 2017 · 17 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@theobouwman
Copy link

Is this a bug report?

Yes

Have you read the Bugs section of the Contributing to React Native Guide?

Yes

Environment

  1. react-native -v: 0.45 & 0.46.1
  2. node -v: v6.9.1
  3. npm -v: 3.10.8
  4. yarn --version (if you use Yarn): 0.17.6

Then, specify:

  1. Target Platform (e.g. iOS, Android): Android
  2. Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra

Steps to Reproduce

  • Create a new react-native project using react-native init ExampleProject
  • Add auth0 with yarn add react-native-auth0 and link it react-native link react-native-auth0
  • And configure the Android project: https://github.com/auth0/react-native-auth0#configuration
  • Add Redux, React Navigation and a few other JS libraries.

Expected Behavior

App should run without any kind of errors.

Actual Behavior

When I want to run the app with react-native run-android after writing some code and adding logic without touching the native Java code and with a successful build, I get this error:

BUILD SUCCESSFUL

Total time: 10.072 secs
Running adb -s 0259749fb8c21037 reverse tcp:8081 tcp:8081
Starting the app on 0259749fb8c21037 (adb -s 0259749fb8c21037 shell am start -n com.woodyapplication/com.woodyapplication.MainActivity)...
Starting: Intent { cmp=com.woodyapplication/.MainActivity }
Error type 3
Error: Activity class {com.woodyapplication/com.woodyapplication.MainActivity} does not exist.

I managed to fix this with the following hacks:

  • creating a new project and copy the JS code over (which is not a solution)
  • replace the package name com.woodyapplication with com.woody.application (or something else). This fixes it for a few runs but then the error message appears again.

I've tested this with RN 0.45 and RN 0.46.1 the bug appears on both versions

@ViGi-P
Copy link

ViGi-P commented Jul 12, 2017

@theobouwman Check whether the following values are same,

  • package (usually line 2) in /android/app/src/main/AndroidManifest.xml

  • applicationId (usually line 90) in defaultConfig section of /android/app/build.gradle

  • Line 1 of /android/app/src/main/java/com/paysack/MainApplication.java

  • Line 1 of /android/app/src/main/java/com/paysack/MainActivity.java

@hramos
Copy link
Contributor

hramos commented Jul 12, 2017

It looks like the repro steps require adding several other libraries. I wonder if you can provide a minimal repro that shows this is indeed an issue in RN?

@theobouwman
Copy link
Author

@hramos the Auth0 library requires the MainActivity to have the launchMode as singleTask. Could that be the cause of this bug?

@thevolcanomanishere
Copy link

@theobouwman try adding the following to android/settings.gradle

include ':app'

Mine was missing that line because I was messing around. I assume that means that gradle skips compiling the actual app and just compiles 3rd party stuff eg

rootProject.name = 'AppName'

include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app')
include ':app'

@endel
Copy link

endel commented Oct 30, 2017

@thevolcanomanishere saved my life! I've removed that line (include ':app') by accident, when removing some duplicated entries of plugins.

@jenskuhrjorgensen
Copy link

I got the same error when adding mutiple build variants to app/build.gradle with different applicationIdSuffix's. According to this unmerged PR, it seems to be a well known RN problem :(

@MrToph
Copy link

MrToph commented Nov 12, 2017

@jenskuhrjorgensen Thanks that's what caused this error for me.

I was using CodePush and had several buildTypes (releaseStaging) defined in android/app/build.gradle.

After restoring it to just debug and release, it works again

@jenskuhrjorgensen
Copy link

jenskuhrjorgensen commented Nov 12, 2017

@MrToph FYI I'm still using different buildTypes with applicationIdSuffix, but I run my Android app using e.g. ./gradlew installStagingDebug or ./gradlew installStagingRelease from within the android folder.

@stale
Copy link

stale bot commented Jan 11, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 11, 2018
@stale stale bot closed this as completed Jan 18, 2018
@marcoliceti
Copy link

I had the same issues and it turned out that the cause was a previously installed app with the same name that wasn't properly uninstalled.

https://medium.com/@thehenrytsai/react-native-troubleshooting-history-c876adda2d67

@Chiamaka
Copy link

I had the same issues and none of the above fixes worked for me. Here's what did:

  • Check your android files (Settings.gradle, app/build.gradle, and MainApplication.java) for any duplications. I was playing around with react-native link and a particular package appeared twice and that was messing up my build.

NOTE: The app crashed on opening it. The error in the terminal still persists but the app runs on the device (emulator & physical device)

@santoshJAVA
Copy link

santoshJAVA commented Feb 10, 2018

i am suffering from same issue.please help

Error type 3
Error: Activity class

"react-native": "0.49.3",
"react": "16.0.0-beta.5"

@miakachammy
Copy link

This helped me. 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.

@ethanyuwang
Copy link

Having the same problem here

@wswoodruff
Copy link

wswoodruff commented Feb 17, 2018

Yes I uninstalled my react-native app on my Android phone and was met with this error. I followed @miakachammy's steps and re-ran react-native run-android and things worked as expected! I guess the launcher doesn't uninstall apps for all users when you drag it to uninstall?? ¯\_(ツ)_/¯

@manupedreira
Copy link

I was having the same issues and none of the above solutions fixed it and cd android && ./gradlew clean was doing nothing for me.
This worked though: cd android && ./gradlew installReactnativeDebug.
And this seems to work too: react-native run-android --variant=reactnativeDebug. Apparently, indicating the version solves the issue.

@willdady
Copy link

willdady commented May 6, 2018

My project has multiple build types where each build type specifies applicationIdSuffix in build.gradle. I was able to get mine working by specifying the appIdSuffix argument e.g.

react-native run-android --variant=staging --appIdSuffix 'staging'

Not sure why it doesn't just honor the applicationIdSuffix defined in the variant?

@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests