Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Build error with a android project with 2 flavours #28

Closed
hiworld75018 opened this issue Mar 5, 2017 · 2 comments
Closed

Build error with a android project with 2 flavours #28

hiworld75018 opened this issue Mar 5, 2017 · 2 comments

Comments

@hiworld75018
Copy link

hiworld75018 commented Mar 5, 2017

Hi, I am trying to use aspects on an android project but build failed with the exception

Execution failed for task ':app:transformClassesWithExtractJarsForInternalDebug'.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithExtractJarsForInternalDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
...
Caused by: java.lang.RuntimeException: error
at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.parseScopeLevelFolders(IntermediateFolderUtils.java:444)
at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.parseTypeLevelFolders(IntermediateFolderUtils.java:411)
at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.computeNonIncrementalInputFromFolder(IntermediateFolderUtils.java:116)
at com.android.build.gradle.internal.pipeline.IntermediateStream.asNonIncrementalInput(IntermediateStream.java:132)
at com.android.build.gradle.internal.pipeline.TransformTask.computeNonIncTransformInput(TransformTask.java:246)

What I did to use aspectJX

  • add an android library ("aspectjx") to the android studio project - to hold JoinPoint(s)
  • add dependencies to this library: appCompat and 'org.aspectj:aspectjrt:1.8.9'
  • add to settings.gradle: include ':app', ':aspectjx'
  • add to project gradle:
    resolutionStrategy { cacheChangingModulesFor 0, 'seconds' }
    dependencies {... classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.9'}
  • add to app grade:
    apply plugin: 'android-aspectjx'
    aspectjx { includeJarFilter 'android.context' excludeJarFilter '.jar' }
    dependencies {
    ...
    compile 'org.aspectj:aspectjtools:1.8.9'
    compile project ':aspectjx'
    }

My objective is to add a join point in android.context.Context.

Note: my app has 2 "flavors" (public and internal), hence the "transform...InternalDebug", and no join point has been defined yet.

Did I miss something ?
Thanks

@firefly1126
Copy link
Contributor

firefly1126 commented Mar 13, 2017

Execution failed for task ':app:transformClassesWithExtractJarsForInternalDebug' occurs when two or more java class files conflict. your project dependencies the library(aspectjx) and the jar(com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.9) at the same time, it is the reason.

@hiworld75018
Copy link
Author

hiworld75018 commented Mar 14, 2017

I am not sure to understand:

  1. the project declares the classpath to the plugin library (gradle-android-plugin-aspectjx),
  2. the custom android library "aspectjx" contains an @aspect public class and a LibrarySDK class (like the AspectJ demo) and depends on appcompat and aspectjrt libraries,
  3. the app has 2 dependencies (aspectjtools and the "aspectjx" android library), and triggers the plugin at build time.

I can't see where two or more classes conflict... The gradle console gives me this log before failing:

:app:transformClassesWithAspectTransformForInternalDebug
aspect start..........
excludeJar:::[...]
directoryInput:::[...]/.android/build-cache/.../output/data-binding
excludeJar:::[...]/aspectjx/build/intermediates/bundles/default/classes.jar
directoryInput:::[...]/app/build/intermediates/classes/internal/debug
aspect do work..........
Found @DeclareAnnotation while current release does not support it (see 'org.aspectj.weaver.bcel.AtAjAttributes')
aspect jar merging..........
aspect done...................
:app:transformClassesWithAspectTransformForInternalDebug spend 2948ms
:app:transformClassesWithExtractJarsForInternalDebug FAILED
:app:transformClassesWithExtractJarsForInternalDebug spend 2ms
:app:buildInfoGeneratorInternalDebug
:app:buildInfoGeneratorInternalDebug spend 1ms

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithExtractJarsForInternalDebug'.
    ...

To get around the problem, is there any way to restrict code weaving to a few classes, using IncludeJarFilter and ExcludeJarFilter ?

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

No branches or pull requests

2 participants