12

So I'm getting the MainActivity does not exist error, it might be because I renamed the package and app from bomber to Bomber and changed the appId from com.bomber to cool.bomber.android

I've checked the AndroidManifest, the activity source files and the build.gradle file but I can't seem to find what's the mistake

Error message

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

app/build.gradle

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "cool.bomber.android"
...

AndroidMaifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="22" />

<application
  android:name=".MainApplication"
  android:allowBackup="true"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:launchMode="singleTask"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="com.google.intent.category.CARDBOARD" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:host="foo.app.goo.gl" android:scheme="http"/>
        <data android:host="foo.app.goo.gl" android:scheme="https"/>
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

android/app/src/main/java/cool/bomber/android/MainActivity.java

package cool.bomber.android;    
import com.facebook.react.ReactActivity;

public class MainActivity extends ReactActivity {
    @Override
    protected String getMainComponentName() {
        return "Bomber";
    }
}

I'm not sure what else I should be looking at to debug.

MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460

4 Answers4

8

You need to uninstall the application properly.

If it does not work from the phone, you can use cmd

adb uninstall "package name"

DeveloperApps
  • 763
  • 7
  • 16
1

Add package name in manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="cool.bomber.android">

and still not working than write full package name like this

<application
  android:name="cool.bomber.android.MainApplication"
  android:allowBackup="true" >

<activity
    android:name="cool.bomber.android.MainActivity"
    >

and make sure this is the right path

and in CMD write this:

 cd android & gradlew clean 
      or maybe
 cd android && ./gradlew clean 

and than run react-native run-android

Make sure when you write this code you are at root of your project folder

Or Else:

Follow this to refresh whole project after changing package using android studio.

Sagar Chavada
  • 5,169
  • 7
  • 40
  • 67
0

For me the problem was that I had added tools:node="replace" to my android/app/src/debug/AndroidManifest.xml:

<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" tools:node="replace"/>

I had added that based on someone recommending it for some other issue and it caused the infamous Error type 3 to appear. Once I got rid of it, the problem went away:

<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning"/>

Cheers, Alvaro

Alvaro Mendez
  • 134
  • 2
  • 13
0

I had to reinstall the app for the problem to be resolved

Vladyslav Zavalykhatko
  • 15,202
  • 8
  • 65
  • 100