Gradle only downloads .aar.asc from Maven Central

2019-03-05 23:31发布

问题:

I freshly deployed an Android library named TypedPreferences. I used it in another Android project for some days. Suddenly, it stopped working - dependencies cannot be found any longer. I noticed that Gradle only downloads one file when I clean the project:

Download http://repo1.maven.org/maven2/info/metadude/android/typed-preferences/ \
  1.0.0/typed-preferences-1.0.0.aar.asc

These are build files of my pet project:

build.gradle:

// Top-level build file where you can add configuration 
// options common to all sub-projects/modules.

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

allprojects {
    repositories {
        mavenCentral()
        maven {
            url "${System.env.HOME}/.m2/repository"
        }
        maven {
            url "https://github.com/novoda/public-mvn-repo/raw/master/releases"
        }
    }
}

app/build.gradle:

apply plugin: 'android'
apply plugin: 'idea'

idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.0.+'
    compile 'com.android.support:appcompat-v7:19.0.+'
    compile 'com.squareup.okhttp:okhttp:1.3.+'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
    compile 'com.fasterxml.jackson.core:jackson-core:2.2.+'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+'
    compile 'com.novoda:sqliteprovider-core:1.0.+'
    compile 'com.androidmapsextensions:android-maps-extensions:2.1.+'
    compile 'com.google.android.gms:play-services:3.2.+'
    compile 'info.metadude.android:typed-preferences:1.0.0'
}

As you can see, I also enable Gradle to look into my local Maven cache here:

maven {
    url "${System.env.HOME}/.m2/repository"
}

I deleted the relevant folders to avoid Gradle loading stuff from there.

There might be a misconfiguration in the build.gradle files of the library - please find them here:

  • Library files

Please tell me also whether I can test your fix locally without deploying to Maven Central.

回答1:

Looks like the packaging element of the published POM has the wrong value. It should be aar, not aar.asc.



回答2:

Also, you always can force the type of artifact to download. Just add dependency like:

compile "group:artifact:version@type"

And in your case it will be

compile "info.metadude.android:typed-preferences:1.0.0@aar"

That's it.