Home > Java > javaTutorial > Why Does My Android NDK Project Throw a `ClassNotFoundException` for My Activity?

Why Does My Android NDK Project Throw a `ClassNotFoundException` for My Activity?

Barbara Streisand
Release: 2024-12-04 07:32:16
Original
922 people have browsed it

Why Does My Android NDK Project Throw a `ClassNotFoundException` for My Activity?

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]]
Copy after login

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");
}
Copy after login

However, the corresponding activity declaration in AndroidManifest.xml was specified as follows:

<activity android:name="android.app.POMActivity">
Copy after login

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">
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template