Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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.
–
–
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"
<activity android:name="com.irrlicht.example1.POMActivity"
Right click on your project and select Properties.
Select Java Build Path from the menu on the left.
Select the Order and Export tab.
From the list make sure the libraries or external jars you added to your project are checked.
Finally, clean your project & run.
You may also check this answer.
–
–
–
–
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.
–
–
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.
–
If the project was compiling just before, you can try to clear the cache using :
./gradlew clean
./gradlew cleanBuildCache
or for windows
gradlew cleanBuildCache
https://developer.android.com/studio/build/build-cache.html
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
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">
–
–
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.
–
–
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'
–
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.
–
–
–
Open "AndroidManifest" file and check for errors
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.
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" />
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 :)
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
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.
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"
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
–
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
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
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
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.
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.
–
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
.