Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

java.lang.NoClassDefFoundError #200

Closed
sunqihui222 opened this issue Sep 27, 2020 · 11 comments
Closed

java.lang.NoClassDefFoundError #200

sunqihui222 opened this issue Sep 27, 2020 · 11 comments

Comments

@sunqihui222
Copy link

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) 

请问大佬,这是为什么?

@taolin2107
Copy link

同样有这个问题!

@awushensky
Copy link

awushensky commented Oct 2, 2020

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

@brunoduan
Copy link

假设在你的主aar工程里面embed了aar A,但A里面implementation了aar B,那么你可能需要这样写:
embed (A) {
transitive = false
}
api B
这样当你的宿主工程引用你的主aar工程时,也会依赖B,从而避免NoClassDefFoundError之类的错误。

@kezong
Copy link
Owner

kezong commented Oct 12, 2020

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?

@awushensky
Copy link

awushensky commented Oct 12, 2020

@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

dependency_tree

@kezong
Copy link
Owner

kezong commented Oct 13, 2020

@awushensky
Could you attach a sample project or send a simple sample to my email?
It's best to describe the steps of reproduction

@awushensky
Copy link

yes, I'll put together a sample project in the next few days.

@awushensky
Copy link

@kezong This project reproduces the problem. It works with version 1.2.16 and breaks with version 1.2.17 and 1.2.18.

https://github.com/awushensky/EmbedSampleApplication

@kezong
Copy link
Owner

kezong commented Oct 23, 2020

@awushensky thank you, I will check it.

@kezong
Copy link
Owner

kezong commented Oct 26, 2020

@awushensky Thanks for the feedback,this bug has fixed in 1.2.19.

@awushensky
Copy link

Thanks so much @kezong !

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants