Gradle - Failed to resolve

怎甘沉沦 提交于 2019-12-12 03:24:05

问题


I know there are multiple threads on this already but not a single fix worked so I figured I must have a unique issue or be making a stupid error that someone smart can point out.

I am trying to use the Realm Recyclerview (found here : https://github.com/thorbenprimke/realm-recyclerview)

However I cannot get the gradle sync to go beyond error 29,13 Failed to resolve com.github.thorbenprimke:realmr-ecyclerview:0.9.12

My app build.gradle file looks like this :

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'
}

and the other one looks like this:

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
}

Thanks!


回答1:


in the build.gradle file inside android {}, add this line

dexOptions {
    javaMaxHeapSize "4g"
}

like

android {
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

if its still not building, you might have to enable multidex

Look at this Stack Overflow post for how to enable multidex

gradle - Android Studio build too slow multidex application




回答2:


I faced the same issue and resolved by adding maven repository URL like this

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

Hope this might helps you.




回答3:


I had the same problem. Solved it by adding below code to build.gradle

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


来源:https://stackoverflow.com/questions/35244697/gradle-failed-to-resolve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!