AndroidStudio常见问题:
Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:- Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network) - The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart) - Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
系统提示有两种解决问题的方式,我的情况下两种方法都是不可行的。后来发现是因为Gradle版本与当前AndroidStudio使用的版本不一致导致的。
- Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Error:The SDK Build Tools revision (24.0.0) is too low for project ‘:app’. Minimum required is 25.0.0
Update Build Tools version and sync project
Open File
Error:The SDK Build Tools revision (24.0.2) is too low for project ‘:photoedit’. Minimum required is 25.0.0
Update Build Tools version and sync project
Open File
这两种问题性质是一样的,都有两种解决方法。第一种:修改版本号为25.0.0;第二种:点击 Update Build Tools version and sync project直接更新
- 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)
这种问题也是比较常见的,而且点击下载时通常是解决不了问题的。
解决方式:
(1)在工程目录下找到gradle文件夹下的gradle-wrapper.properties文件
(2) 修改distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip的版本号(比如3.3),具体修改成什么版本,参照自己其他的项目
- compile、implementation 、 api三者的区别:
(1).之前在使用AndroidStudio引用外部库的时候,我们通常会使用compile fileTree(include: [‘.jar’], dir: ‘libs’),但是在AndroidStudio升级到3.0版本的时候,又新增了两个引用方式implementation fileTree(dir: ‘libs’, include: [‘.jar’])和api fileTree(include: [‘*.jar’], dir: ‘libs’),而compile 则变成了一个过时的方法。
(2).其实implementation 和api是将引用的功能进行细化,比如A、B两个module,B是A的依赖库,B中使用implementation 方法依赖glide库,那么如果在A中使用glide库的话需要重新引用;如果B使用的是api方法引用glide库,那么A可以直接使用glide,
(3).我感觉implementation 相当于类中的private;api相当于类中的public,和compile功能相同。
5.
Error:Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
解决方式:
(1)将project中的的build.gradle文件中的 classpath ‘com.android.tools.build:gradle:2.1.2’版本参照你的其他项目修改成可用的版本,重新编译完成
6.使用Androidstudio自带的模拟器时,出现“/dev/kvm not found ”错误,需要在https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager下载最新插件,安装之后重启Androidstudio就可以了
7.Androidstudio添加的svn提交信息中文乱码,可以按照图示方式设置一种可以兼容中文的字体,修改过字体之后,代码区域的字体也会改变