android-gradle-aspectj icon indicating copy to clipboard operation
android-gradle-aspectj copied to clipboard

Please, help

Open Adm123Git opened this issue 5 years ago • 7 comments

Please, help me..! I'm newbie in android...

My project gradle.build:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.archinamon:android-gradle-aspectj:4.1.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

My app gradle.build:

apply plugin: 'com.android.application'
apply plugin: 'com.archinamon.aspectj'

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.3'
    defaultConfig {
        applicationId 'com.example.test'
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName '1.0.0'
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
    productFlavors {
    }
}

dependencies {
.........................
}

Pjoject compiling normal. Try start on device and... Method com/archinamon/api/ClasspathFileCollection.getBuildDependencies()Lorg/gradle/api/tasks/TaskDependency; is abstract

What can I do?

Adm123Git avatar May 02 '20 08:05 Adm123Git

My setup is probably not the proper way, I have not really messed around with it yet since it currently "works" for what I am doing. I designed it based off of another post discussing issue with newer versions of this plugin which is why I am using 3.4.0. One major problem I always run into is after 5 or so builds/rebuilds, I need to invalidate caches and restart IntelliJ due to Archinamon files still being used. Probably due to my build.gradle setup.

My app build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.archinamon.aspectj'
buildscript {
    repositories {
        google()
        maven { url "https://jitpack.io" }
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "com.archinamon:android-gradle-aspectj:3.4.0"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.aspectideaone"
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions{
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation project(':coupleaspects') //android library with my aspects
    implementation 'com.google.android.material:material:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

aspectj {
    includeAspectsFromJar 'coupleaspects'
    debugInfo true
    ajcArgs << '-referenceInfo' << '-warn:deprecation' << '-verbose'
} 

My android library build.gradle

apply plugin: 'com.android.library'
apply plugin: 'com.archinamon.aspectj-provides'

buildscript {
    repositories {
        google()
        maven {url "https://jitpack.io" }
        mavenCentral()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "com.archinamon:android-gradle-aspectj:3.4.0"
    }
}

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"


    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions{
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

aspectj {
    debugInfo true
    ajcArgs << '-referenceInfo' << '-warn:deprecation' << '-verbose'
}

Didn't put anything in project build.gradle file.

Hope this helps.

MatthewBerk avatar May 02 '20 21:05 MatthewBerk

MatthewBerk, tnhank you! I'll try it soon

Adm123Git avatar May 03 '20 06:05 Adm123Git

Update your gradle-wrapper.properties file with below version.

distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip

rahuljain88 avatar May 11 '20 09:05 rahuljain88

Setting Gradle to 6.3 and min SDK to 24 solves this error.

m0skit0 avatar May 27 '20 22:05 m0skit0

@Adm123Git did any of the above suggestions work for you? if so, please mark this issue as resolved

jdvp avatar Jun 19 '20 19:06 jdvp

Hi, My project requires minSDK = 16, which version of the plugin should you use?

Thanks!

cyangibm avatar Jun 23 '20 23:06 cyangibm

Hi, My project requires minSDK = 16, which version of the plugin should you use?

Thanks!

Hi! At least you have to use corresponding version of gradle and aspectj plugins. You may use aspectj 4.1.0 with Gradle 6.3+ and AndroidGradlePlugin 3.6.+ Or, aspectj 4.2.0 with Gradle 6.3+ and AndroidGradlePlugin 4.0.+

No other requirement on minSdk should not affect your build.

Archinamon avatar Jul 14 '20 17:07 Archinamon