Thursday, 18 October 2018

Failed to resolve variable '${project.groupId}'

I migrate my project to AndroidX and I got these errors when building the project:

[TAG] Failed to resolve variable '${project.groupId}'   
[TAG] Failed to resolve variable '${project.version}'   
[TAG] Failed to resolve variable '${project.groupId}'   
[TAG] Failed to resolve variable '${project.version}'   
[TAG] Failed to resolve variable '${project.groupId}'   
[TAG] Failed to resolve variable '${project.version}'   

I already tried several possible solutions:

  • Clean Project
  • Invalidate Cache and Restart
  • Set enableJetifier to false
  • Add option --refresh-dependencies to the compiler settings

Here is my project gradle file:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.google.gms:google-services:4.0.0'
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://jitpack.io'
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

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

And here is my app gradle file:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    signingConfigs {
        //not showing this
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "my.app.package"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 59
        versionName "1.5.2"

        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true

    }
    dataBinding {
        enabled = true
    }
    // workaround for "duplicate files during packaging of APK" issue
    // see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
    packagingOptions {
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'

        //Workaround to an issue due to google play-services 11.0.0 + rxJava
        exclude 'META-INF/rxjava.properties'
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release_config

        }
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix " - debug"
            debuggable true
        }
    }

    flavorDimensions "public"

    productFlavors {
        //not useful to show this
    }
}

ext {
    supportLibVersion = '28.0.0'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation 'org.jetbrains:annotations-java5:15.0'
    implementation project(path: ':security')

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'

    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
    implementation 'com.google.guava:guava:22.0-android'
    implementation 'com.google.android:flexbox:0.2.3'
    implementation 'com.google.code.gson:gson:2.8.0'

    implementation 'com.hannesdorfmann.fragmentargs:annotation:3.0.2'
    annotationProcessor 'com.hannesdorfmann.fragmentargs:processor:3.0.2'

    implementation 'com.f2prateek.dart:dart:2.0.0'
    annotationProcessor 'com.f2prateek.dart:dart-processor:2.0.0'

    implementation 'com.google.dagger:dagger:2.2'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.2'

    implementation 'com.couchbase.lite:couchbase-lite-android:1.4.1'
    implementation 'com.couchbase.lite:couchbase-lite-android-sqlcipher:1.4.1'

    implementation 'com.squareup.retrofit2:retrofit:2.2.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.2.0'

    implementation 'com.wang.avi:library:1.0.5'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.jaredrummler:twodscrollview:1.0.1'

    implementation 'com.arasthel:asyncjob-library:1.0.3'
    implementation('org.simpleframework:simple-xml:2.7.1') {
        exclude group: 'xpp3', module: 'xpp3'
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'stax', module: 'stax'
    }

    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava:1.1.6'

    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
    testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

    implementation 'com.github.daniel-stoneuk:material-about-library:2.2.1'
    implementation 'org.apache.commons:commons-lang3:3.4'

    implementation('com.github.hotchemi:permissionsdispatcher:3.0.1') {
        exclude module: "support-v13"
    }
    annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:3.0.1"

    implementation 'com.pascalwelsch.compositeandroid:activity:27.0.0'
    implementation 'com.pascalwelsch.compositeandroid:fragment:27.0.0'

    implementation 'commons-codec:commons-codec:1.10'

    implementation 'com.jakewharton.timber:timber:4.7.1'
    implementation 'com.firebase:firebase-jobdispatcher:0.8.5'


}

apply plugin: 'com.google.gms.google-services'

// https://stackoverflow.com/a/49981467/3520621
configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains' , module:'annotations'
}


UPDATE

I run gradlew assembleDebug --stacktrace --debug --info and here are some more info:

...
Caused by: org.gradle.api.artifacts.transform.ArtifactTransformException: Failed to transform file 'dagger-compiler-2.2.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
...
Caused by: java.lang.RuntimeException: Failed to transform 'C:\Users\me\.gradle\caches\modules-2\files-2.1\com.google.dagger\dagger-compiler\2.2\e411f732e5cd9697cdb291f6073b0d6ee2352023\dagger-compiler-2.2.jar' using Jetifier. Reason: The type does not support '.' as package separator! Received 'java.lang.Object;Ljava.lang.Class'.. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.

So it seems jetifier and dagger are the cause, but jetifier is necessary for the migration to AndroidX and I don't want to remove dagger.

If I set android.enableJetifier=false I have more than 50 issues about DataBinding.



from Failed to resolve variable '${project.groupId}'

2 comments:

  1. NZeTA for New Zealand
    On August 2019, the Government of New Zealand implemented the NZeTA to facilitate obtaining an authorization to visit the country for Tourism and Transit purposes. The new online process is valid for 2 years and allows multiple entries to New Zealand.

    NZeTa can be easily obtained online, simplifying the process to enter New Zealand by offering travelers the option to apply directly online for a travel authorization.

    The eTA for New Zealand grants its holder multiple entries to the country during its 2-year validity. Holders of the NZeTA are generally allowed to stay in the country for stays of up to 90 days from their date of arrival in New Zealand. Passports must have a minimum validity of at least three (3) months from the expected date of departure from New Zealand.

    Visitors traveling to New Zealand for short-term stays can apply to have a NZeTA to travel to and within the country. To be able to obtain a valid eTA travel authority to visit New Zealand, travelers should complete an NZeTA online application. The online New Zealand eTA application is straightforward and simple to complete. To get the New Zealand eTA, citizens of eligible countries are required to carefully fill out an online application form.

    ReplyDelete