其他分享
首页 > 其他分享> > Android项目依赖性需要不同版本的Android Gradle插件

Android项目依赖性需要不同版本的Android Gradle插件

作者:互联网

我的Android项目的gradle构建失败,因为我的项目的依赖项需要较旧版本的android gradle插件:

Download https://repo1.maven.org/maven2/org/springframework/android/spring-android-core/1.0.1.RELEASE/spring-android-core-1.0.1.RELEASE.jar
Download https://repo1.maven.org/maven2/org/springframework/android/spring-android-rest-template/1.0.1.RELEASE/spring-android-rest-template-1.0.1.RELEASE.jar
Download https://repo1.maven.org/maven2/org/springframework/spring-asm/3.0.7.RELEASE/spring-asm-3.0.7.RELEASE.jar
Download https://repo1.maven.org/maven2/org/springframework/spring-core/3.0.7.RELEASE/spring-core-3.0.7.RELEASE.jar
Download https://repo1.maven.org/maven2/org/springframework/security/spring-security-crypto/3.1.3.RELEASE/spring-security-crypto-3.1.3.RELEASE.jar
Download https://repo1.maven.org/maven2/org/springframework/social/spring-social-core/1.0.2.RELEASE/spring-social-core-1.0.2.RELEASE.jar
Download https://repo1.maven.org/maven2/org/springframework/android/spring-android-auth/1.0.1.RELEASE/spring-android-auth-1.0.1.RELEASE.jar
Download https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.1.1/jackson-annotations-2.1.1.jar
Download https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.1.1/jackson-core-2.1.1.jar
Download https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.1.2/jackson-databind-2.1.2.jar

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':myapp'.
> Could not resolve all dependencies for configuration ':myapp:classpath'.
   > Could not find any version that matches com.android.tools.build:gradle:0.7.+.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml
         https://maven.fabric.io/public/com/android/tools/build/gradle/maven-metadata.xml
         https://maven.fabric.io/public/com/android/tools/build/gradle/
     Required by:
         phase1:myapp:unspecified > com.jakewharton.hugo:hugo-plugin:1.1.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 20.894 secs

我的项目使用com.android.tools.build:gradle:1.0.0,但是依赖项com.jakewharton.hugo正在寻找gradle:0.7. .

这是我的gradle构建文件.

顶级build.gradle:

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

allprojects {
    repositories {
        mavenCentral()
    }
}

子项目build.gradle:

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.jakewharton.hugo:hugo-plugin:1.1.0'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'hugo'

android {
    compileSdkVersion 20
    buildToolsVersion '21.1.2'
    defaultConfig {
        minSdkVersion 13
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    productFlavors {
    }
}
..
..
..

在Github上查找Hugo,我确认1.1.0版确实要求版本0.7. ,但最新代码(未发布)使用新版本(1.1.0)

有没有办法允许Hugo使用旧版本进行构建,而用新版本进行项目的其余部分构建?

要么

我将顶级Hugo source directory from Github复制到了我的项目中.我如何告诉gradle在那找到hugo插件?

解决方法:

我们遇到了同样的问题.如果将存储库从jcenter()更改为mavenCentral(),它将解决此问题.也可以同时具有两个存储库.

标签:version,gradle,build-tools,android
来源: https://codeday.me/bug/20191028/1954650.html