Could not find any version that matches org.robolectric:robolectric:2.3.+

不想你离开。 提交于 2019-12-11 12:07:49

问题


When syncing my Gradle project in Android Studio, I get the following error:

Error:Could not find any version that matches org.robolectric:robolectric:2.3.+. Required by: gradle:android:unspecified

I assume I am missing a repository in my build.gradle file. I'm new to Gradle and Maven, so I'm not sure what I should put. Any suggestions?

Here are my build.gradle files:

Project:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
        classpath 'com.github.jcandksolutions.gradle:android-unit-test:1.2.+'

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

allprojects {
    repositories {
        mavenCentral()
    }
}

Module:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "bbct.android.common"
        minSdkVersion 11
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    signingConfigs {
        release
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        lite {
            applicationId "bbct.android"
            versionCode 15
            versionName "0.6.2"
        }
        premium {
            applicationId "bbct.android.premium"
            versionCode 14
            versionName "0.6.2"
        }
    }
    def Properties props = new Properties()
    def propFile = new File('signing.properties')
    if (propFile.canRead()) {
        props.load(new FileInputStream(propFile))

        if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
                props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
            android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
            android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
            android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
            android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
        } else {
            println 'signing.properties found but some entries are missing'
            android.buildTypes.release.signingConfig = null
        }
    } else {
        println 'signing.properties not found'
        android.buildTypes.release.signingConfig = null
    }
}

apply plugin: 'android-unit-test'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.google.android.gms:play-services:4.2.42'
    liteCompile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
    androidTestCompile ('com.squareup:fest-android:1.0.8') {
        exclude group: 'com.android.support'
    }
    testCompile 'junit:junit:4.10'
    testCompile 'org.robolectric:robolectric:2.3.+'
}

回答1:


As I said in the comments, try dropping the plus sign. Technically, it shouldn't make a difference (hence why I was hesitant to post it as an answer), but as I stated, I'm pretty sure this has happened to me in the past.

I'm glad it solved your problem. :)



来源:https://stackoverflow.com/questions/24708230/could-not-find-any-version-that-matches-org-robolectricrobolectric2-3

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