【问题标题】:Failed to resolve common open file gradle.build无法解析公用打开文件 gradle.build
【发布时间】:2018-11-20 00:41:57
【问题描述】:

在过去的 6 个小时里,我一直在为这个错误而苦苦挣扎,但我无法解决。我直接从 nextgis github 导入了项目。 请找出问题所在以及如何纠正它。 这里's 错误截图

这里是包含错误的模块中的 build.gradle 文件

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 37
        versionName '2.5.7.1'
        buildConfigField "String", "CLIENT_ID", "\"Im6GFdPPuPM09BnvFb3EacFZyq8TpRBSAAex7JDZ\""
    }
    productFlavors {
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

repositories {
    mavenCentral()
    maven {url "https://maven.google.com"}
    maven {
        url  "http://dl.bintray.com/krazykira/maven"
    }

    google()
    jcenter()

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':maplib')
    compile 'com.4ert:easypicker:0.2.12'
    compile 'com.github.yukuku:ambilwarna:2.0.1'
    compile 'com.jzxiang.pickerview:TimePickerDialog:1.0.1'
    compile 'com.github.miguelbcr:TableFixHeaders-Wrapper:0.2.0'
    compile 'com.android.support:appcompat-v7:26.1.0'

    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support:preference-v7:26.1.0'
    compile 'com.appyvet:materialrangebar:1.4'
}

【问题讨论】:

标签: android android-studio android-gradle-plugin build.gradle gis


【解决方案1】:

当我在 Gradle:project 中编写这段代码时解决了

 buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
  repositories {
      google()
      jcenter()
  }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【讨论】:

    【解决方案2】:

    在将工作项目从一台计算机 git pull 到另一台计算机后,我遇到了同样的问题。最终解决的问题是确保项目 gradle 文件列出 google() 并在 jcenter() 之前拥有它。 ProjectDir/build.gradle 中的最终工作表如下所示:

    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    

    我正在使用 Gradle 4.4 和 Android Studio Gradle 插件 3.1.3

    我不知道为什么它在一台计算机上运行而不在另一台计算机上运行。

    【讨论】:

    • 我缺少订单。将 jcenter() 交换到 google() 下。它工作正常。谢谢
    • 这一定是一些奇怪的缓存问题,但是,是的,我可以确认这会有所作为。之前:在一台机器上工作,但不在另一台机器上工作。之后:适用于两者
    • 工作!。 . . .谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-06
    • 2015-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多