代码之家  ›  专栏  ›  技术社区  ›  nhoxbypass

未能解析变量'${animal.sniffer.版本}“当迁移到AndroidX时

  •  95
  • nhoxbypass  · 技术社区  · 6 年前

    Android Studio 3.2 Beta5 将我的项目迁移到 AndroidX公司

    错误:[TAG]无法解析变量'${animal.sniffer.版本}'

    错误:[TAG]无法解析变量'${junit.版本}'

    完全清理和重建不起作用!有人知道怎么解决这个问题吗?


    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
    }
    

    应用程序/生成.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'
    
    11 回复  |  直到 4 年前
        1
  •  112
  •   Beto    6 年前

    我用两个步骤来解决这个问题

    1) 文件->使缓存无效/重新启动。。。 enter image description here

    2) 生成->清理项目 enter image description here

        2
  •  32
  •   Just The Highlights Konstantin Burov    6 年前

    在更新我的生成.gradle归档 AndroidX Test dependencies . 结果我忘了删除旧的junit依赖项。因此,对我来说,解决方法只是删除以下依赖项:

    dependencies {
        ...
        testImplementation 'junit:junit:4.12'
    }
    
        3
  •  17
  •   Dhaval Patel    6 年前

    android {
         ...
    
         //Add the following configuration in order to target Java 8.
         compileOptions {
             sourceCompatibility JavaVersion.VERSION_1_8
             targetCompatibility JavaVersion.VERSION_1_8
         }
    }
    
        4
  •  14
  •   Vince    6 年前

    滑翔

    科特林:

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

    爪哇语:

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

    确保在您的梯度属性:

    android.useAndroidX=true
    android.enableJetifier=true
    

    资料来源: https://github.com/bumptech/glide/issues/3124

        5
  •  6
  •   Jee Mok ecanf    5 年前

    通过转到主目录并键入 flutter clean

        6
  •  4
  •   M. Usman Khan    5 年前

    defaultConfig {
    ...
    ...
    //        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        7
  •  4
  •   pamobo0609    5 年前

    如果你在使用 Kotlin ,如果不使用 kapt 项目中使用的任何批注处理器的版本。
    Glide ,这可能发生在 Dagger2 , Butterknife
    如果你同时使用 Java 您需要保留这两个依赖项,如下所示 $glideVersion 是的预定义版本 ):

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

    如果你在 唯一的项目 依赖性应该单独工作。

    编辑
    Androidx . 是一个很好的重构,但是在迁移时它会导致一些依赖项崩溃。主流图书馆已经更新到 安卓立德
    如果我提供的解决方案没有解决这个问题,您可以查看一下您的依赖项,并确保它们使用 安卓立德 也。

    编辑2
    卡普特 能处理吗 java 文件也是。 卡普特 一个人就能搞定,没必要两样都留着 卡普特 annotationProcessor 依赖关系。

        8
  •  3
  •   Raj    6 年前

    尝试删除此行:

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

    从的buildscript/repositories部分生成.gradle文件。

        9
  •  2
  •   Minh Pham    6 年前

    试穿套装android.enableJetifier=错误在梯度属性. 然后使缓存失效/重新启动。。。在Android Studio中

        10
  •  1
  •   Shubham Pandey    6 年前

    修复在4.2.0中,使用更高版本的googlegms jar。

    尝试更改:

    类路径'com.google.gms网站:谷歌-服务:4.0.1'

    在此版本中:

    希望这能起作用。。。

        11
  •  1
  •   ikhsanudinhakim    5 年前

    如果您使用的是匕首或巴特利夫,请务必更新到最新版本。或者,如果您的项目中使用了另一个注入库,您可以尝试检查它是否支持androidx或不支持。

    我也发现了同样的错误,问题出在我的匕首和黄油刀上。通过更新到最新版本来修复它。

        12
  •  1
  •   Pedro Molina    5 年前

    Android版本:4.10.2

    我用三个简单的步骤解决了这个问题: 首先我在下面添加了公共规范yml: (有两个识别空格)

    module:
      androidX: true 
    

    在下面加上这两行梯度属性,我在android上有这个/梯度属性,在项目文件夹中。

    android.useAndroidX=true
    android.enableJetifier=true
    

    flutter clean
    

    也许你必须停止设备,然后再运行一次。

        13
  •  0
  •   Gab Ledesma    6 年前

    我通过将firebase依赖项更新到最新版本来解决这个问题。

        14
  •  0
  •   Ahsan Malik    4 年前

    在我的项目中添加了butterknife之后,我遇到了这个错误。

    我建议 this

    我是如何解决的:

    1.添加以下代码生成.gradle(模块:应用程序)

    android {
      ...
      // Configure only for each module that uses Java 8
      // language features (either in its source code or
      // through dependencies).
      compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
      }
    }
    
        15
  •  -1
  •   Hanoch Moreno    5 年前

    我通过刷新cahche(而不是使其无效-这也会清除本地历史)来修复它:

    1. 在梯度属性文件,注释行org.gradle.caching=真.
    2. 在梯度属性文件,取消注释行
    3. 重建,清理。

    就这样!

        16
  •  -1
  •   double-beep hudson solomon    5 年前

    转到“文件”并单击“使缓存失效”并重新启动。

    build.gradle 文件。

    推荐文章