193

I'm currently working on a project in which I have to use purely native ndk. It worked when I try running an helloworld example from Irrlicht engine source. Then I try using it in my project following the same format of that example. But I got:

03-14 01:40:05.308: E/AndroidRuntime(799): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.irrlicht.example1/android.app.POMActivity}: java.lang.ClassNotFoundException: Didn't find class "android.app.POMActivity" on path: DexPathList[[zip file "/data/app/com.irrlicht.example1-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.irrlicht.example1-2, /system/lib]]

while running my project.

Here is my main.cpp file:

#include <android/log.h>
#include <jni.h>
#include <android_native_app_glue.h>
#include "android_tools.h"
#ifdef _IRR_ANDROID_PLATFORM_
void android_main(android_app* app)
{
__android_log_print(4 , "pom" , "nothing");
}

#endif

in Android.mk:

LOCAL_PATH := $(call my-dir)/..
IRRLICHT_PROJECT_PATH := $(LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := Irrlicht
LOCAL_SRC_FILES := /home/karthik/Android/Essentials/ogl-es/lib/Android/libIrrlicht.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := HelloWorldMobile1
LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ -pipe -fno-exceptions -fno-rtti -fstrict-aliasing
LOCAL_C_INCLUDES := -I ../../include -I /home/karthik/Android/Essentials/ogl-es/include -I /home/karthik/Android/json/jsoncpp-src-0.5.0/libs/linux-gcc-4.8 -I /home/karthik/Android/json/jsoncpp-src-0.5.0/include/json 
LOCAL_SRC_FILES :=  android_tools.cpp main.cpp
LOCAL_LDLIBS := -lEGL -llog -lGLESv1_CM -lGLESv2 -lz -landroid -ldl 
LOCAL_STATIC_LIBRARIES := Irrlicht android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)

And I have given Activity name in AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.irrlicht.example1"
    android:versionCode="1"
    android:versionName="1.0">
...
<application android:icon="@drawable/irr_icon" android:label="HelloWorldMobile1" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:debuggable="true">
        <activity android:name="android.app.POMActivity"
        android:label="HelloWorldMobile1"
        android:launchMode="singleTask"
        android:configChanges="orientation|keyboardHidden"
        android:screenOrientation="portrait"
        android:clearTaskOnLaunch="true">
        <meta-data android:name="android.app.lib_name" android:value="HelloWorldMobile1" />                     

What is the mistake I am doing here? I'll post full code if necassary.

Karthik Sivam
  • 2,505
  • 3
  • 18
  • 24

44 Answers44

92

I tried all possible options but result is zero. Finally i found correct solution which is helpful for me. Just go to disable Instant Run Go to File -> Settings -> Build,Execution, Deployment -> Instant Run -> Uncheck the checkbox for instant run. Run your app once and this apk file work properly..

Ashik Abbas
  • 1,127
  • 9
  • 6
  • 12
    This is the correct answer for Android Studio. I can't believe that Instant Run is still so buggy to the extend that you have to turn it off in order to avoid nasty surprises... – Ognyan Oct 01 '17 at 10:54
  • 2
    I have been looking for this answer for days, even weeks! Although not critical, this issue has been on the back of my mind, not giving me peace. Never thought instant run was the one triggering this. My app worked fine when launched via adb, but always crashed with ClassNotFound runtime expection when manually installing it via apk. – Răzvan Barbu Oct 20 '17 at 09:52
  • 9
    That's not the solution to me. I had disabled the instant run – Terranology Mar 15 '18 at 16:36
  • After disabled the options. Please restart your android studio – Ashik Abbas May 04 '18 at 13:55
  • omg i don't know why instant run is the culprit but it is indeed, thanks man. – KingKongCoder May 22 '18 at 17:22
  • Can instant run turned on again after this? I can't make it work again.. – Ryde Jul 29 '18 at 04:38
  • why i am uncheck this chekbox and restart android studio, the issue still exist. Caused by: java.lang.ClassNotFoundException: Didn't find class "com.yryg.hjk.device.MainActivity1" on path: DexPathList[[zip file "/data/app/com.yryg.hjk.device-1.apk"], thanks a lot ,and running on virtual device is OK, on device(huawei p6 android version 4.4) is not work. – Bingchean Jun 18 '19 at 03:07
  • @Bingchean, do you use MultiDex? – CoolMind Jul 16 '19 at 11:39
  • Now is Apply changes, see https://android-developers.googleblog.com/2019/08/android-studio-35-project-marble-goes.html – AITAALI_ABDERRAHMANE Nov 25 '19 at 15:58
  • 27
    can't find instant run in modern android studio :( – Liker777 Jun 16 '21 at 17:55
  • There's no intant run in AS Artic Fox – Pedro Santangelo Dec 27 '21 at 20:25
  • I don't know that disabling Instant Run is a fix to this issue anymore: "unlike Instant Run, Apply Changes does not modify your APK." https://android-developers.googleblog.com/2019/08/android-studio-35-project-marble-goes.html – petestmart Jul 28 '22 at 22:18
72

This seems to be problem in your case. The relative path of your activity in manifest is not correct:

<activity android:name="android.app.POMActivity"

replace this with :

<activity android:name=".POMActivity"

or

<activity android:name="com.irrlicht.example1.POMActivity"
Sushil
  • 8,250
  • 3
  • 39
  • 71
62

I had a similar problem, here's my solution:

  1. Right click on your project and select Properties.
  2. Select Java Build Path from the menu on the left.
  3. Select the Order and Export tab.
  4. From the list make sure the libraries or external jars you added to your project are checked.
  5. Finally, clean your project & run.

You may also check this answer.

mnsalim
  • 947
  • 6
  • 16
  • 1
    This is the correct solution to the question. I have tested this with my libgdx game with the same errors found as the above. I found these errors by using the log generated with my phone (samsung galaxy S6). Once I applied this solution, all of my issues were solved. –  Nov 06 '16 at 02:41
  • 38
    I cannot find Properties from right click of project. May be I am stupid. :( – Zin Min Mar 25 '17 at 12:03
  • 15
    I can't find properties either, anybody figure out how to navigate to the listed page – Skyler Jul 08 '17 at 00:12
  • 20
    This is a solution for the Eclipse IDE. There is no default 'project.properties' file in Android Studio. It can be created though. – Bot Oct 06 '17 at 04:56
  • 4
    The provided solution is only applicable for Eclipse IDE. – mnsalim Mar 10 '20 at 09:00
  • 1
    @Zin Min, you're not stupid, telling someone to 'right click on a project' is just terrible advice. Right click where? In your file manager? Do we need to close the project in Android Studio if it's already open? – default123 Aug 01 '23 at 03:26
40

The deletion of app on device and cleaning of project works for me

Vlad
  • 7,997
  • 3
  • 56
  • 43
  • 2
    This worked for me too with react native. I opened the android folder with Android Studio and then build -> clean project. Rebuilt it with `react-native run-android` – pinguinos Apr 03 '20 at 20:46
  • Did the same as comment above and it worked ! Thanks ! – EldenChris May 29 '20 at 15:30
31

Just try Clean Project & Rebuild Project.

nicolas asinovich
  • 3,201
  • 3
  • 27
  • 37
  • 3
    Under "Build" menu. Select **Build -> Clean Project** and then **Build -> Rebuild Project** – kangkyu Feb 11 '18 at 22:17
  • This would imply that the app only crashes locally, bu the crash also occurs in a release version, so this isn't really a solution. – David Jan 27 '20 at 13:51
27

I should understand the problem by just seeing

dex errors

But it took a half day to fix the issue. I fixed it by following the instructions on the Android Developers page: https://developer.android.com/studio/build/multidex.html

First, add this to build.gradle file:

defaultConfig {
    ...
    minSdkVersion 15 
    targetSdkVersion 33
    // Enabling multidex support.
    multiDexEnabled true
}

 dependencies {
     compile 'com.android.support:multidex:1.0.0'

 }

Then extend the Application class with the MultiDexApplication class as instructed on the above link (or declare the application class in AndroidManifest.xml or override attachBaseContext() function if it is not possible to extend the application class).

That's all, and it solved the problem.

Community
  • 1
  • 1
Akash Bisariya
  • 3,855
  • 2
  • 30
  • 42
  • 1
    Adding multi-dex is useful only when you pass the reference count limit (56k), and it is *very* unstable and *very* unreliable prior to Lollipop. This should be used to fix problems as a last resort. – milosmns Aug 30 '16 at 09:39
  • then what should be the solution according to you – Akash Bisariya Aug 30 '16 at 10:35
  • I'm just saying that multi-dex causes more trouble than it helps, which is clearly stated on the developer website. I wouldn't be here looking for an answer if I had one, would I? – milosmns Aug 30 '16 at 10:43
  • 1
    Ok thanks for the info , Please update here if you found a good solution , it would be a great help. – Akash Bisariya Aug 30 '16 at 11:51
  • 2
    Adding the line in dependencies above did it for me. – gadildafissh Sep 13 '17 at 06:50
  • 1
    After doing that, I needed to clean and rebuild the project. – Mohamed ElSawaf Dec 13 '18 at 23:06
  • But according the official doc, we don't need to add multidexEnable when our app' targetSDKVersion >= 21. Additional, multiDexEnable can only solve NoClassDefFoundError, ClassNotFoundException can't be resolved – YouCii Aug 31 '22 at 08:40
25

This exception can also occur when you have a custom view in your layout like this:

<com.example.MyView
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

and you change the view's package name from "com.example" to something different, but you forget to change it in the layout as well.

petrnohejl
  • 7,581
  • 3
  • 51
  • 63
  • 2
    This was helpful for a different reason. Check your spelling. I had a misspelled class name causing the original issue. – Berry Wing Jun 08 '19 at 14:19
18

If the project was compiling just before, you can try to clear the cache using :

./gradlew clean

or

./gradlew cleanBuildCache

or for windows

gradlew cleanBuildCache

https://developer.android.com/studio/build/build-cache.html

Romuald
  • 545
  • 1
  • 7
  • 16
15

for anyone who comes across this problem now, with android studio 4.0+ you just have to enable java 8 as mentioned here

android {
    defaultConfig {
            ...
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
Amr
  • 1,068
  • 12
  • 21
13

the solution for me was : performing ./gradlew --stop command in android studio terminal. After that just clean and rebuild the project.

aligur
  • 3,387
  • 3
  • 34
  • 51
11
  1. delete the bin folder
  2. change the order of librarys
  3. clean and rebuild

worked for me.

crazyjune
  • 349
  • 3
  • 5
10

For any one who is having multidex enable write this

inside build.gradle

apply plugin: 'com.android.application'

android {
 defaultConfig {
      multiDexEnabled true
  }
 dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:multidex:1.0.1'
}

write a class EnableMultiDex like below

import android.content.Context;
import android.support.multidex.MultiDexApplication;

public class EnableMultiDex extends MultiDexApplication {
    private static EnableMultiDex enableMultiDex;
    public static Context context;

    public EnableMultiDex(){
        enableMultiDex=this;
    }

    public static EnableMultiDex getEnableMultiDexApp() {
        return enableMultiDex;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();

    }
}

and in AndroidManifest.xml write this className inside Application tag

 <application
    android:name="YourPakageName.EnableMultiDex"
    android:hardwareAccelerated="true"
    android:icon="@drawable/wowio_launch_logo"
    android:label="@string/app_name"
    android:largeHeap="true"
    tools:node="replace">
Manohar
  • 22,116
  • 9
  • 108
  • 144
  • How does `enableMultiDex` affect? In my case `javaMaxHeapSize "4g"` didn't help. – CoolMind Feb 18 '19 at 11:13
  • @CoolMind Its just an application class which extends `MultiDexApplication` . It is necessary if you want to use multidex – Manohar Feb 18 '19 at 11:23
  • Agree. I use either `MultiDexApplication` or `attachBaseContext` (see https://developer.android.com/studio/build/multidex). – CoolMind Feb 18 '19 at 11:46
8

Open "AndroidManifest" file and check for errors
or
check whether you have declared that activity name (which we forget when we copy+paste class of activity).

in my case i had replaced all occurrences "com" with "ctrl"+"shift"+"R" command, which also changed the names of activities (which started with com) in manifest.

sifr_dot_in
  • 3,153
  • 2
  • 33
  • 42
7

We don't need to have customized Application class which extends MultiDexApplication. Instead, we can have like this on AndroidManifest.xml

<application
android:name="android.support.multidex.MultiDexApplication"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

And along with this on build.gradle(Module:app),

defaultConfig {
      ...

      // Enabling multidex support.
      multiDexEnabled true
}

dependencies {
     ... 
     compile 'com.android.support:multidex:1.0.2'
}

Thanks.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Abdul Gaffar
  • 581
  • 2
  • 7
  • 16
7

I faced this Issue multiple times and they're all solved by disabling Instant Run.

Mohamed Nageh
  • 1,963
  • 1
  • 19
  • 27
  • Tried multiple solutions, this little thing solved the problem, unbelievable! – FraK Jul 18 '18 at 17:20
  • @FraK, the most rated solution contains this advice. Though I had already unchecked Instant Run (several years it has bringing many bugs). – CoolMind Feb 18 '19 at 09:37
7

In my case this issue arose because of Kotlin. In my existing code there was a class that was written Kotlin. I built the app, it installed and as soon as first activity opened app crashed. in the logcat this error was being shown. I then updated my Kotlin version from Kotlin website in app gradle file. Build the app again and it worked fine then.

Harry .Naeem
  • 1,245
  • 3
  • 20
  • 33
  • Wow, I have a 99%-Kotlin project What to do? :) – CoolMind Feb 18 '19 at 11:51
  • Can you please check, with Kotlin version is compatible with your underlying Android Studio. Its just a guess. take a look – Harry .Naeem Feb 19 '19 at 06:38
  • I have AS 3.3.1 and Kotlin 1.3.21. They are latest stable. Sorry, I suppose, all solutions described above and below are not suitable to my situation. – CoolMind Feb 19 '19 at 07:07
  • yep, Thanks for reminding me, it indeed is the "kapt" annotation processor and kotlin plugin that needed to be added to my build.gradle coz, I did a 100% conversion from java to Kotlin but forgot that the compiler needs to be Kotlin compiler to generate the classes. Tricky to remember but effective constraint to watchout when dealing with kotlin environment. – mahee96 Nov 17 '21 at 23:04
6

When you are using multidex , then try to extend your application class with MultiDexAppication instead of Application and override below method this required for Android below 5.0 (because 5.0 and above support to the multidex)

@Override
protected void attachBaseContext(Context base)
{
    super.attachBaseContext(base);
    MultiDex.install(BaseApplication.this);
}

and in dependencies add this

compile 'com.android.support:multidex:1.0.1'
Cocoatype
  • 2,572
  • 25
  • 42
  • We should override this method if we extend from `Application`. Why should we override in a case of `MultiDexAppication`? – CoolMind Feb 18 '19 at 08:37
5

One possible reason would be the incorrect path of the activity in the Apps AndroidManifest.xml file. Register the activity with in your AndroidManifest.xml with full relative path like below.

<activity android:name="<full_path>.ActivityName" />
Akki
  • 775
  • 8
  • 19
4

Just Change your folder name from lib to libs ,

Then you will see some error marks in your project, to resolve this rightClick on project >

Properties > Java Build Path > libraries :

Remove all the library with red marks on it, then apply > ok > after that clean your project . TADA see the magic :)

hemantsb
  • 2,049
  • 2
  • 20
  • 29
3

after i tried the given answers, i found out another reason for the same Exception, that i had to add the library i'm using manually to my main library through

Right click on my main library > 
Properties > 
Android > 
Go to the very bottom of the screen and click (Add) > 
Select my other library that caused the crash >
Apply

before this solution, i used the "Fix Project setup" from within the .java file in eclipse, but this did not work, so i had to add it manually here and it worked

Ahmed Adel Ismail
  • 2,168
  • 16
  • 23
3

I was getting this crash only on Samsung Lollipop devices and this solution worked for me.

dexOptions {
     preDexLibraries false
}

I'm posting this answer here because this question is currently the highest ranked search result on Google for this crash and none of the above answers worked for me.

blinkmacalahan
  • 499
  • 5
  • 18
3

This was similar to my problem--after adding a Kotlin file to an all Java app, my app kept crashing when I would access a view that used a Kotlin file. I shut down Android Studio and restarted it, and it prompted me with a message saying "Kotlin not configured, would you like to configure?", which then solved my problem.

What this ultimately did is add the following classpath line inside my project build.gradle file:

buildscript {
   ...
   dependencies {
      ...
      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
      ...
   }
   ...
}
ConcernedHobbit
  • 764
  • 1
  • 8
  • 17
3

I am going with @hofs but displaying where should put minifyEnabled.

In Module Gradle, Add minifyEnabled false in Debug block will work for me.

 android {
    compileSdkVersion 28
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.korechi.roamioapp"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
          minifyEnabled false
        }
    }

}
Arpit Patel
  • 7,212
  • 5
  • 56
  • 67
2

The following solution worked for me...

I tried everything mentioned above but still didn't get my app running. I have react-native app running on latest version of gradle 4+ and android studio.

I had the issue where if i run react-native run-android it was failing with issue saying its not able to find MainApplication class...i.e ClassNotFoundException

I was able to resolve the issue when I updated my gradle.properties to use the compiler D8.

I added:

android.enableD8=true

to my gradle.properties

Doc Details here: https://android-developers.googleblog.com/2017/08/next-generation-dex-compiler-now-in.html

nkadu1
  • 223
  • 1
  • 3
  • 9
2

If you are enabled minifyEnabled and shrinkResources to true in your app gradle file. You need to add the following line in proguard-rules.pro file

-keep class com.yourpackage_name.** { *; }

because minification is removed some important classes in our apk file.

Naveen Kumar M
  • 7,497
  • 7
  • 60
  • 74
  • This is not a good solution because it excludes all of your source files from resource shrinking. Only exclude only the files that are really necessary instead, otherwise you inflate your apk size. – Yannick Jun 15 '20 at 13:30
2

i had this issue before and the comments here helped in the past but this time it did not. i checked my proguard configuration and i removed the following lines and then it worked so proguard can have something to do with this error:

 -optimizationpasses 5
        -overloadaggressively
        -repackageclasses ''
        -allowaccessmodification
        -dontskipnonpubliclibraryclassmembers
j2emanue
  • 60,549
  • 65
  • 286
  • 456
2

Ashik abbas answer (disable Instant Run) work for me, but i need Instant Run, finally i found solution which is helpful for me. just disable minifyEnabled. go to build.gradle(Module: app) in debug block and disable minifyEnabled:

debug {
            minifyEnabled false

        }
hofs
  • 469
  • 4
  • 12
1

As per my understading i get the issue after update android studio 2.1 to 2.3 due to the instant feature my application will not run when i copy the apk from output and put into the sdcard. For this problem i build the apk from build option do build apk in android studio.

1

In my case, I used the old namespace library while my project was set up making use of androidx one.

The solution was to replace android.support.design.widget.BottomNavigationView component with the right one to escape from support library: com.google.android.material.bottomnavigation.BottomNavigationView.

Andrii Artamonov
  • 622
  • 8
  • 15
1

in my case, I define the Activity in Manifest.xml and forgot to create any activity. So I created Activity and define it in manifest and my error solved!

Sana Ebadi
  • 6,656
  • 2
  • 44
  • 44
1

For me what i ended up doing is disabling minifyEnabled false and shrinkResources false

David Innocent
  • 606
  • 5
  • 16
1

My issue was because of kapt.

I had a dependency on Hilt but the kapt method wasn't working, so I changed it to implementation just so it would compile.

The reason kapt was showing an error was because I was missing this plugin at the top of the file:

id("org.jetbrains.kotlin.android")
beyondtheteal
  • 729
  • 6
  • 15
0

If you receive this error after removing some gradle dependency, check your manifest and make sure that you removed all entries corresponding that dependency.

dees91
  • 1,211
  • 13
  • 21
  • Please don't add the [same answer](http://stackoverflow.com/a/40729213/5292302) to multiple questions. Answer the best one and flag the rest as duplicates. See [Is it acceptable to add a duplicate answer to several questions?](http://meta.stackexchange.com/questions/104227/is-it-acceptable-to-add-a-duplica‌​te-answer-to-several-questions) – Petter Friberg Nov 21 '16 at 21:00
0

For me the issue appeared after i created a signed APK. To fix it, i generated a new, debug apk using Run / Build APK. After that, Run(cmd+r) works again without this error.

passatgt
  • 4,234
  • 4
  • 40
  • 54
0

I was facing same issue. I tried everything possible for a day, but nothing worked. The dependency which was causing problem was using lower compile sdk, target sdk and min sdk. I created library module for the project, copied all the sources and matched the sdk versions with application sdk versions. And finally it worked like a charm.

PK Gupta
  • 822
  • 10
  • 20
0

I had the same error and some answers mislead me on a newbie issue. I had the wrong package in my custom view descriptor like below. I hope it helps somebody.

<com.my.app.wrong.package.MyActivity
    android:id="@+id/myActivity"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:paddingTop="16dp"
    android:paddingBottom="8dp"
    android:gravity="left" />
lauksas
  • 533
  • 7
  • 14
0

This solved my case:

In my case, I was getting the exception below (note that my application class was causing the exception, not my activity):

ClassNotFoundException: Didn't find class "com.example.MyApplication" on path: DexPathList

I was getting this exception only on devices equal or below API 19, the reason was that I was extending MultiDexApplication() class and overriding attachBaseContext at the same time! When I removed attachBaseContext everything got on track.

class MyApplication : MultiDexApplication() {

override fun onCreate() {
    super.onCreate()
    // ...
}

override fun attachBaseContext(base: Context?) {
    super.attachBaseContext(base)
    MultiDex.install(this)
}

So if you happen to have such case as I had (Which isn't likely), there is no need to extend MultiDexApplication() and override attachBaseContext at the same time, doing one of these actions is enough.

Mostafa Arian Nejad
  • 1,278
  • 1
  • 19
  • 32
0

Flipper isn't working on 0.61.x, so commenting out/removing initializeFlipper(this) in your MainApplication.java should do the trick.

Chill Pill.

Ali Akram
  • 4,803
  • 3
  • 29
  • 38
0

Converting Java code to Kotlin code may cause this problem so configure kotlin in your project may remove this problem

fazal ur Rehman
  • 330
  • 2
  • 5
0

I tried most of the cache related answers - but didn't work,

RCA

 I created broadcast receiver with android studio tool, and it didn't give correct package name,

Actual [ Added By Android Studio ]

 package com.example.app;
 

Expected

 package com.example.app.all_sms_reader;
Mrudul Addipalli
  • 574
  • 6
  • 10
0

src->main->kotlin.......... MainActivity.kt package your_package

import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity() { }

0

This issue occurs when your namespace didn't match with your package. To resolve this issue follow these steps:

Note: If you are changing your application package follow these steps:

  1. create New package you want by right click on java>New>package.
  2. then select all of your code from previous package and drop it in new package. Android studio will refactor for you.
  3. Goto Build.gradle(:app) and change namespace to new package you recently created.
  4. Clean and Rebuild project and your issue will be resolved.
0
  1. Please make sure that activity path is correct in AndroidManifest.xml, if that doesn't work, simply invalidate caches and restart.
  2. If you are trying to convert existing java android project in kotlin, and kotlin is not configured, then you might face same issue: To resolve above: create an new blank Fragment inside your app module, and android studio will automatically configure kotlin for you.

Hope it helps..

-2

delete 'android/app/.settings' folder

or

delete 'android/.settings' folder

or

delete 'android/.build' folder

or

delete 'android/.idea' folder

and

yarn react-native run android

Psychopomp
  • 293
  • 4
  • 9