0

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:

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

JJD
  • 50,076
  • 60
  • 203
  • 339
  • "Suddenly stopped working" is strange. Are you sure the remaining files aren't cached already? (`gradle clean` won't clean the dependency cache.) The first thing to try in such a case is to run with `--refresh-dependencies`. Which Gradle version are you using? The local Maven repo should only be declared if the Gradle build needs to consume the output of a local Maven build (there are no other benefits, only drawbacks). And if it's declared, it should be `mavenLocal()`. – Peter Niederwieser Feb 21 '14 at 19:10
  • The Gradle wrapper I use defines v.1.10. I cleaned the caches (Maven and Gradle) manually by removing the directory of the library. `gradle --refresh-dependencies` downloads the `.pom` and the `.aar.asc`. Still dependencies cannot be found. – JJD Feb 21 '14 at 20:18
  • Try to remove the Maven local declaration, and try to run with `--info` or `--debug`. – Peter Niederwieser Feb 21 '14 at 20:27

2 Answers2

1

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

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • As far as I understand the POM is generated from what I defined in the [build.gradle](https://github.com/johnjohndoe/TypedPreferences/blob/master/Library/build.gradle). Can you spot what is wrong there? – JJD Feb 22 '14 at 13:46
  • `packaging "aar", "jar"` looks suspicious, because there can only be one value for packaging. I don't know where the `aar.asc` comes from. – Peter Niederwieser Feb 23 '14 at 00:09
  • That doesn't mean it's right. Crouton's build script has `packaging "jar", "aar"` (i.e. the reverse order). Perhaps the first value wins, and `jar` is the default packaging type for a POM. This would explain why its published POM doesn't have a `packaging` element. – Peter Niederwieser Feb 23 '14 at 20:38
  • The [Crouton library specifies both types](https://github.com/keyboardsurfer/Crouton/blob/master/library/build.gradle#L108) as well. I will try to adapt the `jar` task which is setup there. – JJD Feb 23 '14 at 21:40
  • As I said, it specifies them in a different order, which may make a difference in practice. Nevertheless, specifying two types is definitely wrong. – Peter Niederwieser Feb 23 '14 at 22:05
  • I changed the `package` settings and deployed a new version. Thank you. – JJD Feb 24 '14 at 19:35
1

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.

ddmytrenko
  • 796
  • 7
  • 16