Android Studio报错问题集锦

时间:2020-12-13 18:40:00

Android Studio使用过程中坑太多,动不动就报错,每次出现问题都是上百度去搜索,需要花费很大的时间和精力才能解决掉问题。

为了以后更高效的使用这款工具,在这里记录下来我已经踩过的坑和即将要踩的坑,希望能为自己也为别人提供些便利,共同学习,共同进步。

 

 公司和家中的电脑用了两个不同版本的studio,先贴下截图做个记录

Android Studio报错问题集锦Android 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: ‘

Android Studio报错问题集锦

 

 

报错2:Sources for ‘Android API 26 Platform‘ not found

这是 Android Studio 关联不上源码导致的

找到~/Library/Preferences/AndroidStudioXXX/options/jdk.table.xml这个文件,手动配置 API 26 Sources 文件路径

Android Studio报错问题集锦

 Android Studio 常见问题

 

报错3:

0