Open averyzhong opened 4 years ago
Hi!
Could you provide please more info:
Hi!
gradle plugin & aspectJ plugin version:
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.archinamon:android-gradle-aspectj:4.2.1'
android version:
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.foo.aop"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
This is also happening for me. It seems to be linked to having multiple variants and using includeJars
- possibly the jars are being included for each variant?
Note, after a little more investigation the additional variants aren't the issue. I've opened a PR that includes a failing test showing the issue ☝️
I'm happy to fix this, but any pointers would be helpful - from what I can tell the processed classes are being included along with the original dependency when the multi dexing is being done?
I have pinpointed the problem as the addition of copying the include jars that resolves #108 and updated my PR to revert this change and add a test for both this issue and 108.
(@Archinamon please review when you can)
@superafroman Hi! Sorry for being offline for so long. I've took a look at your code. It seems have to work, but I'll test in my production project first before commiting public packages.
Thank's for your contribution!
@superafroman This change, which was released in the 4.3.0 version of the plugin today, seems to have re-introduced issue #108
AGP v4.1.0 and android-gradle-aspectj v3.4.0
This branch on my sample project is exhibiting the issue for reference: https://github.com/jdvp/AndroidAspectExample/tree/feature/agp-4.1.0
Stacktrace if interested:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: me.jdvp.androidaspectexample.debug, PID: 5225
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/R$drawable;
at androidx.appcompat.widget.AppCompatDrawableManager$1.<init>(AppCompatDrawableManager.java:63)
at androidx.appcompat.widget.AppCompatDrawableManager.preload(AppCompatDrawableManager.java:57)
at androidx.appcompat.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:336)
at androidx.appcompat.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:286)
at androidx.appcompat.app.AppCompatDelegate.create(AppCompatDelegate.java:230)
at androidx.appcompat.app.AppCompatActivity.getDelegate(AppCompatActivity.java:554)
at androidx.appcompat.app.AppCompatActivity.attachBaseContext(AppCompatActivity.java:107)
at android.app.Activity.attach(Activity.java:7899)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3401)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
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:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.appcompat.R$drawable" on path: DexPathList[[zip file "/data/app/~~oR4sHx3yVPaRSB1KduWpUQ==/me.jdvp.androidaspectexample.debug-I1VyhpPc3vfvewIIUTYhow==/base.apk"],nativeLibraryDirectories=[/data/app/~~oR4sHx3yVPaRSB1KduWpUQ==/me.jdvp.androidaspectexample.debug-I1VyhpPc3vfvewIIUTYhow==/lib/x86, /system/lib, /system_ext/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
com.archinamon.aspectj-ext
aspectj { includeJar 'retrofit2' }
:app:mergeProjectDexDebug spend 560ms Task spend time: 147ms :app:processDebugManifest 64ms :app:mergeDebugResources 1097ms :app:processDebugResources 1952ms :app:kaptGenerateStubsDebugKotlin 121ms :app:javaPreCompileDebug 645ms :app:mergeDebugNativeLibs 977ms :app:kaptDebugKotlin 4456ms :app:compileDebugKotlin 148ms :app:compileDebugJavaWithJavac 1140ms :app:transformClassesWithAspectjForDebug 8485ms :app:dexBuilderDebug 103ms :app:mergeDebugJavaResource 560ms :app:mergeProjectDexDebug
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:mergeProjectDexDebug'.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 20s 24 actionable tasks: 24 executed