APK app project not pulling aar transitive deps

378 views Asked by At

I have an android library project with this gradle build script:

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group 'com.test'
version '0.0.1'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.test.sdk"
        minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    lintOptions {
        abortOnError false
    }
}


dependencies {
    compile 'com.android.support:support-v4:21.0.2'
    compile 'com.google.code.gson:gson:2.3'
}

Then I have an application with this build script:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Google Inc.:Google APIs:19'
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.test.app"
        minSdkVersion 14
        targetSdkVersion 19
        multiDexEnabled true
    }


    signingConfigs {
        release {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled false
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
    }
}

dependencies {
    compile ('com.test:sdk:0.0.1@aar') {
        transitive = true
    }
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:support-v4:21.0.2'
    compile 'com.google.android.gms:play-services:6.1.71'
}

I am using a maven plugin to publish my libraries sdk to my local maven repository: https://github.com/dcendents/android-maven-plugin

I run the install task on my library project and it successfully publishes the library .aar along with the pom file. The pom file lists gson as a compile dependency.

Generated POM file:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test</groupId>
  <artifactId>sdk</artifactId>
  <version>0.0.1</version>
  <packaging>aar</packaging>
  <dependencies>
   <dependency>
     <groupId>com.google.code.gson</groupId>
     <artifactId>gson</artifactId>
     <version>2.3</version>
     <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

When I run my application I get java.lang.NoClassDefFoundError's for the gson classes. Looking through the apk I do not see the gson dep pulled in at all.

I have read that putting the extension '@aar' on the dependency sets transitive to false and does not pull the transitive dependencies. So I added transitive = true. I have also tried it without the '@aar' extension and I run into the same problem.

I am using Android Studio RC1 w/ gradle plugin version 0.14.4.

0

There are 0 answers