HujiangTechnology / gradle_plugin_android_aspectjx

A Android gradle plugin that effects AspectJ on Android project and can hook methods in Kotlin, aar and jar file.
Apache License 2.0
3.94k stars 568 forks source link

与apply plugin: 'kotlin-android-extensions'冲突 #273

Open LinX1874 opened 4 years ago

LinX1874 commented 4 years ago

app.gradle 如果有apply plugin: 'kotlin-android-extensions' 且同时存在 kotlin和java文件时候 编译通过 进入app 报错 java.lang.RuntimeException: Unable to instantiate application com.xxx.xxx.xxxApplication: java.lang.ClassNotFoundException: Didn’t find class “com.xxx.xxx.xxxApplication” on path: DexPathList[[zip file “/data/app/com.xxx.xxx.xxx-2.apk”],nativeLibraryDirectories=[/data/app-lib/com.xxx.xxx.xxx-2, /vendor/lib, /system/lib]]

移除kotlin-android-extensions后正常

LinX1874 commented 4 years ago

如果只有 kotlin 也是正常的

xiachengcheng commented 4 years ago

感谢分享新的思路

StephenGiant commented 4 years ago

我解决的办法是建一个类带aspect注解的类 里面啥都不写 没有这个类是无法正常编译的 很奇怪

xiachengcheng commented 4 years ago

很遗憾的是,引入apply plugin: 'android-aspectjx' 去掉//apply plugin: 'kotlin-android-extensions' 还是会出现 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.test.App" 其中APP就是我的Application类

LinX1874 commented 4 years ago

很遗憾的是,✓apply插件:'android-aspectjx'去掉 // apply插件:'kotlin-android-extensions' 还是会出现 原因:java.lang.ClassNotFoundException:找不到类“ com.test.App” “ 其中APP就是我的应用类

删除 apply plugin: 'kotlin-kapt' 试试

LinX1874 commented 4 years ago

我解决的办法是建一个类带aspect注解的类 里面啥都不写 没有这个类是无法正常编译的 很奇怪

我尝试了在各个地方 写下空的@aspect 但很遗憾没有起到作用

xiachengcheng commented 4 years ago

我觉得是实际工程中,引入了不同的三方库,和aspectJ插件造成冲突导致的。也因此各有各的解法,但是解法不通用。

WinWang commented 3 years ago

还有没有大佬有新的解决的方法?引入了kotlin+jetpack后就不行了,不用jetpack开发组件能正常运行,去掉aop也不太现实,用的地方比较多

ghost commented 3 years ago

我测试没有发现你说的问题,我的工程是java和kotlin混编的,感觉你报的错误可以尝试下MultiDex试试

StephenGiant commented 3 years ago

是你的使用方法有问题 并不是什么兼容问题