Iam getting ClassNotFoundException, and it's causing a RuntimeException during the launch of my Android application.
FATAL EXCEPTION: main
Process: com.example.mquran, PID: 15561
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.mquran/com.example.mquran.QuranActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.mquran.QuranActivity" on path: DexPathList[[zip file "/data/app/~~hynbSxiLbBBszkZOGN7mmw==/com.example.mquran-lzohw1JV0FF52fn5hJr6Cg==/base.apk"],nativeLibraryDirectories=[/data/app/~~hynbSxiLbBBszkZOGN7mmw==/com.example.mquran-lzohw1JV0FF52fn5hJr6Cg==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3914)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4201)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2438)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8663)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.mquran.QuranActivity" on path: DexPathList[[zip file "/data/app/~~hynbSxiLbBBszkZOGN7mmw==/com.example.mquran-lzohw1JV0FF52fn5hJr6Cg==/base.apk"],nativeLibraryDirectories=[/data/app/~~hynbSxiLbBBszkZOGN7mmw==/com.example.mquran-lzohw1JV0FF52fn5hJr6Cg==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:44)
at android.app.Instrumentation.newActivity(Instrumentation.java:1273)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3901)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4201)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2438)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8663)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
2024-01-02 03:17:22.209 15561-15653 libEGL com.example.mquran
this is the manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:exported="true"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="34">
<activity
android:name=".QuranActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have searched alot to solve this error, editing java class but nothing has worked
It is possible that you added the activity in the wrong manifest file, that is in a different source set. Take a look on your packages structure. It's really hard to suggest a solution as the problem source can be more than one.