@androidx.annotation.Nullable报错问题

       Google 2018 IO 大会推出了 Android新的扩展库 AndroidX,提供跨Android版本的向后兼容性。Androidx越往后作用越大,Nullable这一个类在修饰方法调用参数时,这表示该参数可以合法地为空,该方法将优雅地处理它。典型地用于可选参数。

      Androidx中Nullable报错,需要在build.gradle导入依赖:

dependencies {
   
    implementation 'androidx.annotation:annotation:+'
}
如果编译报错
More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'

  build.gradle中还需要添加:

android {
    packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
    }
}

 

你可能感兴趣的:(BUG)