Archinamon / android-gradle-aspectj

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

Could not find com.archinamon:Aspectj-gradle:1.1.2 #9

Closed LuanLuna closed 8 years ago

LuanLuna commented 8 years ago

Hi!!! When i try to use your plugin it's happen.

Error:Could not find com.archinamon:AspectJ-gradle:1.1.2.
Searched in the following locations:
    file:/opt/android-studio/gradle/m2repository/com/archinamon/AspectJ-gradle/1.1.2/AspectJ-gradle-1.1.2.pom
    file:/opt/android-studio/gradle/m2repository/com/archinamon/AspectJ-gradle/1.1.2/AspectJ-gradle-1.1.2.jar
    https://repo1.maven.org/maven2/com/archinamon/AspectJ-gradle/1.1.2/AspectJ-gradle-1.1.2.pom
    https://repo1.maven.org/maven2/com/archinamon/AspectJ-gradle/1.1.2/AspectJ-gradle-1.1.2.jar
Required by:
    AspectjTest6:app:unspecified
Archinamon commented 8 years ago

Hi! I've missed to add this: mavenCentral() maven { url 'https://github.com/Archinamon/GradleAspectJ-Android/raw/master' } into buildscript.repositories section. that's why studio can't find the artifact.

LuanLuna commented 8 years ago

Thanks, i can run the app now, but i've created a .aj file in my project, this file has an aspect with one pointcut and one advice, but when i run the app the around advice dont work. I can use native aspectj .aj in my project using your plugin? (I'm using android studio). (I'ts the last question i promise) TestAspect.aj

aspect TestAspect{
    pointcut pointOne(): execution (String MainActivity.getParadigma());

    String around(): pointOne() {
        return "AOP";
    }

}

MainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ((TextView)findViewById(R.id.textView)).setText("Welcome to "+getParadigma());
    }

    public String getParadigma() {
        return "OOP";
    }
}
Archinamon commented 8 years ago

Yes, you can use native aj syntax :) In this code you need to add import for your MainActivity in these two ways: import my.code.MainActivity; or modify your pointcut execution (String my.code.MainActivity.getParadigma()); And then run your app.

LuanLuna commented 8 years ago

Good, it works prefectly :D. Thanks.