android - 带有gradle build 4.1的android studio 3.0.1中的Gradle同步错误

标签 android android-studio compiler-errors android-gradle-plugin build.gradle

Below is the screenshot of the error, Any help will really be appreciated.

每当我加载新项目或创建一个新项目时,都会 pop 此错误,
这个错误让我困扰了2个星期,任何帮助将不胜感激。

最佳答案

安装AS 3.0.1时可能会遇到一些错误。其中最常见的是-

错误1 错误:无法找到Build Tools版本26.0.2“install.build.tools”安装Build Tools 26.0.2并同步项目。

解决方案:在build.gradle文件中更新配置,因为它现在正在寻找API26。如果 checkin SDK Manager,则表明您实际上具有版本27。因此,无需安装的SDK。 API级别26,而是按照以下方式更新build.gradle文件中的配置”:

=> 将compileSdkVersion从26更改为27,并将targetSdkVersion从26更改为27。

错误2 错误:未能找到Build Tools版本26.0.2
“install.build.tools”安装构建工具26.0.2并同步项目。

解决方案:在相同的(build.gradle)文件中,在compileSdkVersion 27下方添加buildToolsVersion“27.0.3”。该代码必须显示为:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.example.android.happybirthday"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

完成这些更改后,工作室应该可以正常工作,您就可以开始开发了。另一种验证方法是,您现在必须在菜单栏中的“工具”下看到“Android”子菜单。

关于android - 带有gradle build 4.1的android studio 3.0.1中的Gradle同步错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48459157/

相关文章:

c - 错误 : expected identifier or '(' before numeric constant

java - 允许在 DVD+R 上编译 DVD+R 上的 java 程序

c++ - 编译器错误 MB_LEN_MAX 的假定值错误

java - 如何使用ArrayList字段迁移Room数据库?

java - Android Studio 3.0 - "Failed to transform file ' gson-2.2.4.jar' 匹配属性 {artifactType=android-classes}”

android - 文件 google-services.json 丢失。没有它,Google 服务插件将无法运行。 (对于 firebase ml 套件)

在 4.4 操作系统版本的 onStart 方法中注册事件总线时出现 java.lang.NoClassDefFoundError

android - 创建用于具有自定义分辨率的模拟的 AVD 没有任何导航按钮

android - PhoneGap : Fetch Contact list with optimize speed

android - 如何借助广播接收器获取相机点击事件?