【问题标题】:Gradle syncing error [duplicate]Gradle同步错误[重复]
【发布时间】:2018-02-07 07:01:28
【问题描述】:

我目前正在 ubuntu 17 上开发 android studio 3.0.2。gradle 同步正在产生问题。我尝试了离线工作和更新 SDK.. 但都没有成功。

【问题讨论】:

  • 问题似乎出在您的 'build.gradle' 中。您能否分享您的该文件以帮助您解决问题。
  • 不要离线工作,连接到网络/互联网。并分享您的项目的 build.gradle 文件。
  • 您可以在 StackOverflow 中找到其中的许多内容。您可以尝试从项目文件夹中清除 gradle 文件。但是,不能保证它会起作用。最好自己找到问题,因为这个问题可能有很多原因。
  • @harshitdixit 尝试以下答案。它可能会帮助您解决问题。

标签: android android-studio android-gradle-plugin


【解决方案1】:

您可以将 build.gradle(Module: app) 替换为:

 apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
defaultConfig {
    applicationId "com.example.goku.myapplication"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
  compile 'com.android.support:appcompat-v7:27.0.2'
  compile 'com.android.support:design:27.0.2'
  compile 'com.android.support.constraint:constraint-layout:1.0.2'
  testCompile 'junit:junit:4.12'
}

还有你的 build.gradle(Project: MyApplication)

buildscript {
repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
  }
}

allprojects {
repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
     }
   }
}
task clean(type: Delete) {
     delete rootProject.buildDir
}

注意:确保您已连接到互联网。 这对你有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-02
    • 2020-01-14
    • 1970-01-01
    • 2016-09-24
    • 2015-08-12
    相关资源
    最近更新 更多