programing tip

AndroidX로 마이그레이션 할 때 변수 '$ {animal.sniffer.version}'을 (를) 해결하지 못했습니다.

itbloger 2020. 7. 20. 07:47
반응형

AndroidX로 마이그레이션 할 때 변수 '$ {animal.sniffer.version}'을 (를) 해결하지 못했습니다.


Android Studio 3.2 Beta5사용하여 프로젝트를 AndroidX 로 마이그레이션하고 있습니다. 앱을 다시 빌드하면 다음 오류가 발생합니다.

오류 : [TAG] 변수 '$ {animal.sniffer.version}'을 (를) 해결하지 못했습니다.

오류 : [TAG] 변수 '$ {junit.version}'을 (를) 해결하지 못했습니다.

완전 청소 및 재 구축이 작동하지 않았습니다! 누구나이 문제를 해결하는 방법을 알고 있습니까?


gradle.properties

android.enableJetifier=true
android.useAndroidX=true

build.gradle

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-beta05'

        classpath 'com.google.gms:google-services:4.0.1'
        classpath "io.realm:realm-gradle-plugin:5.3.1"
        classpath 'io.fabric.tools:gradle:1.25.4'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    }
}

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

app / build.gradle

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.0"
    defaultConfig {
        applicationId "com.iceteaviet.fastfoodfinder"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
        }
    }
    aaptOptions {
        cruncherEnabled = false
    }
}

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

    implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'

    implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
    implementation 'com.google.android.material:material:1.0.0-rc01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc01'
    implementation 'androidx.cardview:cardview:1.0.0-rc01'

    implementation 'com.google.maps.android:android-maps-utils:0.5'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'

    implementation 'com.github.bumptech.glide:glide:4.7.1'

    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

    implementation 'org.greenrobot:eventbus:3.1.1'

    implementation 'de.hdodenhof:circleimageview:2.2.0'

    implementation 'io.realm:realm-android-library:5.3.1'

    implementation 'com.facebook.android:facebook-android-sdk:4.34.0'

    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    implementation 'io.reactivex.rxjava2:rxjava:2.0.2'

    implementation 'androidx.multidex:multidex:2.0.0'

    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
    implementation 'com.google.firebase:firebase-perf:16.0.0'

    implementation 'com.jakewharton.timber:timber:4.7.1'

    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
}

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

두 단계로이 문제를 해결합니다

1) 파일-> 캐시 무효화 / 재시작 ... 여기에 이미지 설명을 입력하십시오

2) 빌드-> 프로젝트 정리 여기에 이미지 설명을 입력하십시오


AndroidX Test dependencies로 build.gradle 파일을 업데이트 한 후 동일한 오류가 발생했습니다 . 이전 junit 종속성을 제거하는 것을 잊었습니다. 그래서 나를 위해 수정은 단순히 다음 종속성을 제거하는 것이 었습니다.

dependencies {
    ...
    testImplementation 'junit:junit:4.12'
}

Adding Java 8 support to build.gradle file fixed issue for me

android {
     ...

     //Add the following configuration in order to target Java 8.
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
}

It seems to be Glide the problem.

I had the same error and I just updated the Glide's dependencies to 4.8 and there is no build errors.

Kotlin :

// Glide
def glide_version = "4.8.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"

Java :

// Glide
def glide_version = "4.8.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"

Be sure to have enabled in your gradle.properties :

android.useAndroidX=true
android.enableJetifier=true

Source : https://github.com/bumptech/glide/issues/3124

Hope this will help you!


Removing the testInstrumentationRunner worked for me:

defaultConfig {
...
...
//        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

If you're using Kotlin, the issue will popup if don't use the kapt version for any annotation processor you use in the project.
As @Vince mentioned the case with Glide, this could happen with Dagger2, Butterknife, etc.
If you're using both Java and Kotlin you'll need to keep both dependencies, as follows (were $glideVersion is a predefined version of Glide):

implementation "com.github.bumptech.glide:glide:$glideVersion"

kapt "com.github.bumptech.glide:compiler:$glideVersion"

If you're on a Kotlin only project, the kapt dependency should work alone.

EDIT
Another thing you should have in mind is if you're already using Androidx. Androidx is a great refactor but when migrating it can cause some of your dependencies to collapse. Mainstream libraries are already updated to Androidx, however, some of them are not and even won't.
If the issue doesn't go away with my provided solution above this edit, you can take a look at your dependencies and make sure they use Androidx as well.

EDIT 2
As @Ted mentioned, I researched back and he's right kapt does handle java files as well. kapt alone will do the trick, no need to keep both kapt and annotationProcessor dependencies.


Try removing this line:

maven { url "https://oss.sonatype.org/content/repositories/snapshots" }

from the buildscript / repositories section of your build.gradle file.

When I added that line, I got the error you described. When I removed it, no longer. That line should only be in the allprojects / repositories section.


Try set android.enableJetifier=false in gradle.properties. Then Invalidate Caches / Restart ... in Android Studio


The fix is in 4.2.0, use the higher version of google gms jar.

Try changing:

classpath 'com.google.gms:google-services:4.0.1'

by this version:

classpath 'com.google.gms:google-services:4.2.0'

Hope this works...


I fixed this by updating the firebase dependencies to the latest.


Fixed it by going to the main directory and typing flutter clean


I fixed it by refreshing the cahche (Instead of invalidating it - which also clears the local history):

  1. in gradle.properties file, comment the line org.gradle.caching=true.
  2. Clean, Rebuild.
  3. in gradle.properties file, un-comment the line org.gradle.caching=true.
  4. Clean, Rebuild.

그게 다야!


파일로 이동하여 캐시 무효화를 클릭하고 다시 시작하십시오.

다시 시작한 후 앱 build.gradle파일 에서 최소 SDK 버전을 증가시킵니다 .

참고 URL : https://stackoverflow.com/questions/51797219/failed-to-resolve-variable-animal-sniffer-version-when-migrate-to-androidx

반응형