AndroidStudio3.0以上版本的坑


原文:https://blog.csdn.net/ytfunnysite/article/details/78864556

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:

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鐨勪笉鍙槧灝勫瓧絎?這里寫圖片描述

文件編碼分為UTF-8編碼和GBK編碼,編譯時使用UTF-8編碼,就會導致某些頁面亂碼。 
這里寫圖片描述 
解決辦法: 
1、下方的UTF-8換成GBK 
2、跳出提示選擇”reload“,此時注釋之類的亂碼會顯示正確。 
3、右下角再選擇UTF-8 
4、跳出提示選擇”convert“,此時編碼從GBK轉為UTF-8。 
5、編譯運行,就不會出現亂碼錯誤了 
6、如果還有提示,哪個文件出錯,就如上轉換該文件,問題解決!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM