温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android Studio3.0升级后使用注意事项有哪些

发布时间:2021-07-12 14:11:43 来源:亿速云 阅读:95 作者:小新 栏目:移动开发

这篇文章主要介绍Android Studio3.0升级后使用注意事项有哪些,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

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升级后使用注意事项有哪些”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI