侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 129953 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

Android Studio3.0升级后使用注意事项及解决方法

2023-06-03 星期六 / 0 评论 / 0 点赞 / 38 阅读 / 2733 字

Gradle plugin最高版本4.*老的项目在使用新版本时,可能会出现gradle plugin冲突的问题Error:Failed to open zip file. Gradle's dependency cach

Gradle plugin最高版本4.*

老的项目在使用新版本时,可能会出现gradle plugin冲突的问题

.
Error:Failed to open zip file. Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network) Re-download dependencies and sync project (requires network)
.

解决方法:

去往gradle安装目录(File->Other Settings->Default Settings,然后可以搜索gradle,右侧有Service directory path可以看到你gradle目录),.gradle/wrapper/dists目录下找到和项目的gradle-wrapper.properties里版本号一致的文件(比如gradle-3.3-all)删除,重新编译即可

Cannot choose between the following configurations,产生这个问题的原因是项目用引用了其他项目,比如compileproject(:library),

解决方法:

Android Studio3.0以后需要使用如下方式:

.
implementation project(path: ':library', configuration: 'default')
.

伴随着 Android Gradle 插件 2.2 版本的发布,近期 android-apt 作者在官网发表声明证实了后续将不会继续维护 android-apt,并推荐大家使用 Android 官方插件提供的相同能力。也就是说,大约三年前推出的 android-apt 即将告别开发者,退出历史舞台,Android Gradle 插件提供了名为 annotationProcessor的功能来完全代替 android-apt,更换的步骤如下:

移除 Module 的 build.gradle 文件中对 android-apt 的相关配置,也就是删除类似下面的配置:     

.
 buildscript {      repositories {        jcenter()      }      dependencies {        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'      }    }    apply plugin: 'com.neenbedankt.android-apt'
.

将 Module 的 build.gradle 文件中使用 apt 引入的依赖修改为使用 annotationProcessor 进行引入,修改前配置如下:

.
    dependencies {     compile 'com.google.dagger:dagger:2.0'     apt 'com.google.dagger:dagger-compiler:2.0'    }
.

修改后配置如下: 

.
   dependencies {      compile 'com.google.dagger:dagger:2.0'      annotationProcessor 'com.google.dagger:dagger-compiler:2.0'    }
.

总结

以上所述是小编给大家介绍的Android Studio3.0升级后使用注意事项,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对..网站的支持!

广告 广告

评论区