AndroidStudio3.0以上版本的坑

1、Error:Failed to resolve: com.android.support:multidex:1.0.2
Add Google Maven repository and sync project
Open File
Show in Project Structure dialog

Error:Failed to resolve: com.android.support:multidex-instrumentation:1.0.2
Add Google Maven repository and sync project
Open File
Show in Project Structure dialog

Error:(23, 0) Cannot set the value of read-only property ‘outputFile’ for object of type com.android.build.gradle.internal.api.LibraryVariantOutputImpl.
Open File
解决:
修改build.gradle脚本,增加google()

2、Error:(604, 5) error: expected reference but got (raw string) @+android:style/Animation.Translucent.
解决:
没有找到好的办法,最后修改gradle的版本,使用4.2.1或者
修改gradle.properties文件,增加以下参数配置
android.enableAapt2=false
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
解决:
修改gradle.properties文件,增加以下参数配置
android.enableAapt2=false

3、Error:Unable to load class ‘org.gradle.api.internal.component.Usage’.
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.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
解决:
修改gradle的版本

4、Error:No such property: FOR_RUNTIME for class: org.gradle.api.attributes.Usage
解决:
将gradle的版本从4.3.1降级到4.2.1

5、乱码
Error:(84, 35) 閿欒: 缂栫爜UTF-8鐨勪笉鍙槧灏勫瓧绗?AndroidStudio3.0以上版本的坑_第1张图片

文件编码分为UTF-8编码和GBK编码,编译时使用UTF-8编码,就会导致某些页面乱码。
AndroidStudio3.0以上版本的坑_第2张图片
解决办法:
1、下方的UTF-8换成GBK
2、跳出提示选择”reload“,此时注释之类的乱码会显示正确。
3、右下角再选择UTF-8
4、跳出提示选择”convert“,此时编码从GBK转为UTF-8。
5、编译运行,就不会出现乱码错误了
6、如果还有提示,哪个文件出错,就如上转换该文件,问题解决!

你可能感兴趣的:(Exception,Android)