Gradle项目同步失败并出现ParseError

时间:2018-09-29 09:28:19

标签: android-studio gradle build build.gradle

Gradle始终无法同步项目。

我收到以下错误消息:

enter image description here

据我所知,解释器在解析模块的build.gradle文件时遇到问题。

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.b.b3"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        maxSdkVersion 28
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }
    buildToolsVersion = '28.0.2'
}

ext {
    supportLibrary = "27.0.2"
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha06'
    implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha06'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation "com.android.support:design:${supportLibrary}"
    implementation 'org.osmdroid:osmdroid-android:6.0.2'
    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'
}

1 个答案:

答案 0 :(得分:3)

您可以在build.gradle文件中检查以下设置吗?

  dependencies {
      classpath 'com.android.tools.build:gradle:xxxxx'
  }

我曾经和你有同样的问题。我不知道为什么但是我调整了上述版本信息,问题解决了。