java.lang.ClassNotFoundException: Didn't find class on path: dexpathlist
While working on a project using purely native NDK, an issue arose when attempting to run the project, resulting in the error message:
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]]
Upon investigating the code, it was discovered that the main.cpp file included the following lines:
#include "android_tools.h" #ifdef _IRR_ANDROID_PLATFORM_ void android_main(android_app* app) { __android_log_print(4 , "pom" , "nothing"); }
However, the corresponding activity declaration in AndroidManifest.xml was specified as follows:
<activity android:name="android.app.POMActivity">
The discrepancy between the activity name in the manifest and the class name in the native code caused the ClassNotFoundException. To resolve the issue, the activity name in the manifest should have been updated to match the native code, as follows:
<activity android:name=".POMActivity">
Once this change was made, the project ran successfully without the ClassNotFoundException.
The above is the detailed content of Why Does My Android NDK Project Throw a `ClassNotFoundException` for My Activity?. For more information, please follow other related articles on the PHP Chinese website!