Archinamon / android-gradle-aspectj

gradle plug-in adding supports of AspectJ into Android project
Apache License 2.0
364 stars 58 forks source link

Support for Gradle plugin 2.0 #7

Closed mykola-dev closed 8 years ago

mykola-dev commented 8 years ago

Seems like aspectj plugin doesn't work with new gradle plugin. I'm using 2.0.0-beta2 with AS 2.0 preview9 I've got compile time error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithInstantRunSlicerForDebug'.
> java.lang.ArrayIndexOutOfBoundsException (no error message)

here is my simple aspect

  @DeclareMixin(value = "@ds.weavingtest.Dagger *")
    public AspectIntefrace declareStuff(final Object instance) {
        return new AspectIntefrace() {
            @Override
            public void showToast() {
                Toast.makeText(((Context) instance), "hello", Toast.LENGTH_SHORT).show();
            }
        };
    }

ps: i've disabled InstantRun and it compiles without errors now. But my mixin doesnt apply to the class so it is crashes on class casting stage:

((AspectIntefrace) this).showToast();

This code works ok on gradle plugin 1.5.0

Archinamon commented 8 years ago

Hello! I've just deployed 1.1.2 artifact that has a fix for slicer task. I've been tested it in my example project and everything works fine. Even more, gradle correctly understands whether aspectJ task made any changes or not.

mykola-dev commented 8 years ago

It works. Thanks!