java.lang.NoClassDefFoundError
sunqihui222 opened this issue · 11 comments
aar 打包成功后,在引用的时候出现Process: com.example.myapplication, PID: 1981
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/pichillilorenzo/flutter_inappwebview/InAppWebViewFlutterPlugin;
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:19)
at ys.dzzhyjdc.MainActivity.configureFlutterEngine(MainActivity.kt:10)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:180)
at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:411)
at android.app.Activity.performCreate(Activity.java:8085)
at android.app.Activity.performCreate(Activity.java:8073)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3870)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8349)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin" on path: DexPathList[[zip file "/data/app/com.example.myapplication-VyQsQ5jdzJx9ctXsOKmvJw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-VyQsQ5jdzJx9ctXsOKmvJw==/lib/arm, /data/app/com.example.myapplication-VyQsQ5jdzJx9ctXsOKmvJw==/base.apk!/lib/armeabi-v7a, /system/lib, /hw_product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:19)
at ys.dzzhyjdc.MainActivity.configureFlutterEngine(MainActivity.kt:10)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:180)
at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:411)
at android.app.Activity.performCreate(Activity.java:8085)
at android.app.Activity.performCreate(Activity.java:8073)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3870)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8349)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
请问大佬,这是为什么?
同样有这个问题!
Thanks for the library! It is very helpful.
Changing from version 1.2.16 to 1.2.17 has caused a similar problem in my app. Resources are no longer accessible on embedded project libraries.
Caused by: java.lang.ClassNotFoundException: Didn't find class "<embedded_package_name>.R$raw" on path: DexPathList
This works correctly on version 1.2.16
假设在你的主aar工程里面embed了aar A,但A里面implementation了aar B,那么你可能需要这样写:
embed (A) {
transitive = false
}
api B
这样当你的宿主工程引用你的主aar工程时,也会依赖B,从而避免NoClassDefFoundError之类的错误。
Thanks for the library! It is very helpful.
Changing from version 1.2.16 to 1.2.17 has caused a similar problem in my app. Resources are no longer accessible on embedded project libraries.
Caused by: java.lang.ClassNotFoundException: Didn't find class "<embedded_package_name>.R$raw" on path: DexPathList
This works correctly on version 1.2.16
@awushensky
Do you try to clean the project?
What version of gradle plugin and gradle you used?
@kezong thanks for responding! I have tried a full git clean -fdx
and a rebuild, but the problem persists.
This is using the following:
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10"
classpath 'com.kezong:fat-aar:1.2.17'
gradle wrapper version 6.4.1
I have attached a diagram that displays the dependency tree that is causing this problem
@awushensky
Could you attach a sample project or send a simple sample to my email?
It's best to describe the steps of reproduction
yes, I'll put together a sample project in the next few days.
@kezong This project reproduces the problem. It works with version 1.2.16
and breaks with version 1.2.17
and 1.2.18
.
@awushensky thank you, I will check it.
@awushensky Thanks for the feedback,this bug has fixed in 1.2.19.
Thanks so much @kezong !