Android Studio使用时遇见的一些问题+解决方法(持续更新)

1.如果编译时出现“ERROR: Plugin with id 'com.android.application' not found.”错误.

解决方法:请在build.gradle文件中添加以下代码。

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
         //版本号请根据自己的gradle插件版本号自行更改
        classpath 'com.android.tools.build:gradle:3.4.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

2.Error:Failed to resolve: com.android.support:support-v4:26.0.0

出现问题的原因:support annotations自25.4.0之后support包不在sdk中更新了,需要用谷歌的maven库,在Project的build.gradle中添加谷歌的地址

解决方法:因此需要我们手动的在Project的build.gradle中添加如下谷歌的地址

allprojects {
        repositories {

            jcenter()
            mavenCentral()

            maven{ url "https://maven.google.com"}
            maven{ url "https://dl.google.com./dl.android/maven2/"}
        }
    }

猜你喜欢

转载自www.cnblogs.com/jiani/p/12945242.html