【问题标题】:Gradle - Failed to resolveGradle - 无法解决
【发布时间】:2016-02-06 18:21:46
【问题描述】:

我知道这已经有多个线程,但没有一个修复有效,所以我认为我一定有一个独特的问题,或者犯了一个聪明的人可以指出的愚蠢错误。

我正在尝试使用 Realm Recyclerview(可在此处找到:https://github.com/thorbenprimke/realm-recyclerview

但是我无法让 gradle 同步超出错误 29,13 无法解决 com.github.thorbenprimke:realmr-ecyclerview:0.9.12

我的应用 build.gradle 文件如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.example.harris.school"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile files('libs/joda-time-2.9.jar')
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'io.realm:realm-android:0.84.1'
    compile 'com.github.thorbenprimke:realm-recyclerview:0.9.12'
}

另一个看起来像这样:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

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

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }

    }
}

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

谢谢!

【问题讨论】:

  • 请您发布您的完整堆栈跟踪。使用 --stacktrace 运行 gradle 命令
  • 构建文件看起来不错。您是否尝试过从命令行运行./gradlew clean assemble --refresh-dependencies

标签: android gradle android-gradle-plugin android-recyclerview realm


【解决方案1】:

在 android{} 内的 build.gradle 文件中,添加这一行

dexOptions {
    javaMaxHeapSize "4g"
}

喜欢

android {
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

如果它仍未构建,您可能需要启用multidex

查看这篇 Stack Overflow 帖子了解如何启用 multidex

gradle - Android Studio build too slow multidex application

【讨论】:

  • 问题不同。无法解析 com.github.thorbenprimke:realmr-ecyclerview:0.9.12 与 mutidex 或 heapsize 无关
【解决方案2】:

我遇到了同样的问题,并通过添加这样的 maven 存储库 URL 解决了

android{
    repositories{
       maven{
          url 'http://repo1.maven.org/maven2'
       }
    }
}

希望这对你有帮助。

【讨论】:

    【解决方案3】:

    我遇到了同样的问题。通过将以下代码添加到 build.gradle 来解决它

    allprojects {
       repositories {
        mavenCentral()
        maven { url "https://jitpack.io" }
        jcenter()
          }
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-16
      • 1970-01-01
      • 2019-04-16
      • 2015-05-10
      • 1970-01-01
      • 2017-04-10
      • 2019-03-27
      相关资源
      最近更新 更多