Archinamon / android-gradle-aspectj

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

Android Studio 3 Compatibility? #62

Open zmorris opened 6 years ago

zmorris commented 6 years ago

This is more of a question but, have you tested the aop-common.zip and aspectj.zip plugins from https://github.com/Archinamon/GradleAspectJ-Android/tree/master/IDE in Android Studio 3?

https://android-developers.googleblog.com/2017/10/android-studio-30.html https://developer.android.com/studio/preview/features/index.html https://developer.android.com/studio/index.html

I'm hesitant to upgrade if it means losing AspectJ on Android for a time. Hopefully they didn't change how plugins work. I'm on a Mac OS Sierra 10.12.6 (16G29).

Thanks!

zmorris commented 6 years ago

I tried it on my friend's Android Studio 3 install and it looks like the GradleAspectJ-Android library has a dependency on Kotlin 1.1.51 maybe which is built into Android Studio 3 now. He tried disabling the builtin plugin and adding the Kotlin library manually but couldn't get it to work. I think that's the only part that didn't work, sorry this is secondhand info.

Archinamon commented 6 years ago

Hi! Sad but these plugins are not working properly within AS 3.0 no more. I did looking for updating them, but not sure I can do it without official sources. These plugins just a c/p that did work on parole.

To say about the second part of your question. I'll look into it in a few days, but that sounds strange. Builtin kotlin has nothing chained with a kotlin's stdlib that is using to compile the plugin's sources. Does any additional info or logs available?

zmorris commented 6 years ago

Ok I bit the bullet and upgraded to Android Studio 3 for a client project. If I enable the plugins:

AOP/@AspectJ Common
AspectJ Support

Android Studio opens without crashing. But if I try to open my .aj file it just shows an error message so I had to disable the plugins. Without them, we mainly lose syntax highlighting and the ability to step through AspectJ files in the debugger.

GradleAspectJ-Android still works however, and I'm able to see my trace at https://github.com/Archinamon/GradleAspectJ-Android/issues/59 being written to the console :-)

I had to comment out the lines for retrolambda but I'm not sure it was needed anyway. From what I understand, it helps AspectJ detect anonymous functions, but I could be wrong about that? I see anonymous class methods like this in the trace:

new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
        // do stuff here
    }
}, 1000);

They appear as MyActivity.1.1.run().

I've updated my tracer example at https://github.com/Archinamon/GradleAspectJ-Android/issues/59#issuecomment-331757834 to work with Android Studio 3. Hope this helps someone.

Archinamon commented 6 years ago

You're right considering the retrolambda. It will generate (desugar, just like gradle 3.0.0 does) synthetics for every lambda expression. So we can easily find and pointcut them! :)

Talking about syntax plugin. That sad, but I have no idea how to support it w/o writing my own implementation of the plugin. The corner circumstances is this plugin is not official port for AS, just my own "adaption". It will work fine in IntelliJ Ultimate (trial too). My mind AS has some incompatible changes with base IntelliJ, that's why these plugins fails to run.