'Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.aol.Application" on path: DexPathList error flutter
I am trying to run a project but I found an error:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.aol.Application" on path: DexPathList[[zip file "/data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/lib/arm64, /data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
So does any one have any idea about the below error:
and this is the related manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aol" xmlns:tools="http://schemas.android.com/tools">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<application
android:name=".Application"
tools:replace="android:label"
android:label="aol"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="${applicationId}.braintree" />
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<!-- TODO: Replace with your real AdMob app ID -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value= "@string/android__admob_ads_id_key" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
</manifest>
this is the full error:
Launching lib\main.dart on Redmi 5 in debug mode...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk... 38.0s
E/AndroidRuntime(14356): FATAL EXCEPTION: main
E/AndroidRuntime(14356): Process: com.example.aol, PID: 14356
E/AndroidRuntime(14356): java.lang.RuntimeException: Unable to instantiate application com.example.aol.Application: java.lang.ClassNotFoundException: Didn't find class "com.example.aol.Application" on path: DexPathList[[zip file "/data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/lib/arm64, /data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
E/AndroidRuntime(14356): at android.app.LoadedApk.makeApplication(LoadedApk.java:993)
E/AndroidRuntime(14356): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5801)
E/AndroidRuntime(14356): at android.app.ActivityThread.-wrap1(Unknown Source:0)
E/AndroidRuntime(14356): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
E/AndroidRuntime(14356): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(14356): at android.os.Looper.loop(Looper.java:176)
/AndroidRuntime(14356): at android.app.ActivityThread.main(ActivityThread.java:6651)
E/AndroidRuntime(14356): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(14356): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/AndroidRuntime(14356): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
E/AndroidRuntime(14356): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.aol.Application" on path: DexPathList[[zip file "/data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/lib/arm64, /data/app/com.example.aol-1JWhf7hk26dkh1US0WG4tg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
E/AndroidRuntime(14356): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
E/AndroidRuntime(14356): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(14356): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(14356): at android.app.Instrumentation.newApplication(Instrumentation.java:1088)
E/AndroidRuntime(14356): at android.app.LoadedApk.makeApplication(LoadedApk.java:987)
E/AndroidRuntime(14356): ... 9 more
Solution 1:[1]
I experienced the same error. In my case, the Application.java
file was under main/java/
. I solved it by creating another folder under the java folder and I put inside it the Application file, so the path becomes as following; main/java/your_folder_name/Application.java
. Don't forget to update the new path in the AndroidManifest
file, so it becomes something like:
.
.
.
<application
<!--Here-->
android:name=".your_folder_name.Application"
tools:replace="android:label"
android:label="aol"
android:icon="@mipmap/ic_launcher">
Another reason, it could also be due to the fact that your Application.java
is in a different package than the one you specified at the AndroidManifest
.
Solution 2:[2]
I see that for newer created Flutter apps android:name
in application
tag from AndroidManifest.xml
is no longer present. If you don't have anything custom in your Activity.kt, you can just delete that XML attribute.
Android docs state that it's optional.
Solution 3:[3]
Remove android:name="com.yourpackage.xxxxx"
<application
android:name="com.yourpackage.xxxxx"
android:label="routingo"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Underscore |
Solution 3 | Geomatik Mühendisi |