Android Studio使用過程中坑太多,動不動就報錯,每次出現問題都是上百度去搜索,需要花費很大的時間和精力才能解決掉問題。
為了以后更高效的使用這款工具,在這里記錄下來我已經踩過的坑和即將要踩的坑,希望能為自己也為別人提供些便利,共同學習,共同進步。
公司和家中的電腦用了兩個不同版本的studio,先貼下截圖做個記錄
報錯1:Could not find any version that matches com.android.support:appcompat-v7:29.+.
Could not find any version that matches com.android.support:appcompat-v7:29.+. Versions that do not match:
26.0.0-alpha1
25.3.1
25.3.0
25.2.0
25.1.1
+ 50 more
Searched in the following locations:
file:/E:/Android/sdk/extras/m2repository/com/android/support/appcompat-v7/maven-metadata.xml
file:/E:/Android/sdk/extras/m2repository/com/android/support/appcompat-v7/
file:/E:/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/maven-metadata.xml
file:/E:/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/
file:/E:/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml
https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/maven-metadata.xml
https://jcenter.bintray.com/com/android/support/appcompat-v7/maven-metadata.xml
https://jcenter.bintray.com/com/android/support/appcompat-v7/
Required by:
project :app
Please install the Android Support Repository from the Android SDK Manager.
Open Android SDK Manager
解決方案:找到自己的項目文件,修改build.gradle文件(注意是Module:app,不是Project下的)
找到這一段
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:29.+' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }
將這一行 implementation 'com.android.support:appcompat-v7:29.+'
改為 implementation 'com.android.support:appcompat-v7:26.+'
或者 implementation 'com.android.support:appcompat-v7:+'
報錯2:Sources for 'Android API 26 Platform' not found
這是 Android Studio 關聯不上源碼導致的
找到~/Library/Preferences/AndroidStudioXXX/options/jdk.table.xml這個文件,手動配置 API 26 Sources 文件路徑
報錯3:導入他人工程時報錯 Could not install Gradle distribution from 'https://services.gradle.org/..."
修改build.gradle文件(注意是Module:app)
把dependencies這一段替換成自己可用項目的
報錯4:
0