Failed to resolve variable '${animal.sniffer.version}' when migrate to AndroidX

前端 未结 16 1167
轻奢々
轻奢々 2021-01-30 04:36

I\'m using Android Studio 3.2 Beta5 to migrate my project to AndroidX. When I rebuild my app I got these errors:

ERROR: [TA

16条回答
  •  悲&欢浪女
    2021-01-30 05:20

    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.

提交回复
热议问题