Android Studio 1.0.2 m2respository gradle issue

2019-07-07 00:44发布

问题:

Using Android Studio 1.0.2, and you are forced to use Gradle 2.2.1, all system variables are correct. With the new update there are issues with older versions of gradle and m2repository. I am trying to import kickflip.io android example (https://github.com/Kickflip/kickflip-android-example).

I am seeing this error:

Could not find com.android.tools.build:gradle:2.2.1.
Searched in the following locations:
    file:/C:/Program Files/Android/Android     Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
    file:/C:/Program Files/Android/Android     Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
Required by:
    :kickflip-android-example-master:unspecified

I've looked in m2repository and see:

C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle\1.0.0

How can I add the 2.2.1 library?

Gradle Wrapper:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip

Top-level build file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.1'
        classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

app/build.gradle:

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

android {
    compileSdkVersion 19
    buildToolsVersion "19.1"

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 19
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.squareup.picasso:picasso:2.2.0'
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
    compile 'io.kickflip:sdk:1.1.1'
}

My error report is extremely long, so won't post it since the formatting gets corrupted when I copy and paste it in. Any help is greatly appreciated.

回答1:

The version of Gradle is 2.2.1, but you're plugging that into the place where the version number of the Android Gradle plugin goes. That's currently at 1.0.0. Instead of this:

    classpath 'com.android.tools.build:gradle:2.2.1'

use this:

    classpath 'com.android.tools.build:gradle:1.0.0'


回答2:

yes, it works.

Firstly the jcenter repository not includes 2.2.1 version. so need to change to 1.0.0/1.0.1