I have a utilities.aar in a intranet maven repo. It uses a few well known jars such as gson. I have defined them as compile dependencies in utilities module's build.gradle as follows
dependencies {
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'commons-codec:commons-codec:1.4'
compile 'org.apache.commons:commons-lang3:3.4'
}
It has been uploaded Artifactory repo on our intranet server using uploadArchives gradle task. The pom file shown on Artifactory is as follows
<?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>adsf.asdf.utils</groupId>
<artifactId>utilities</artifactId>
<version>2.0.0.0</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>23.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
I am building an android app using Android Studio v1.5 build tools 23.0.2 and gradle v2.8. This ADT bundle was downloaded on Jan 2016. My app depends on utilities.aar. It is added to build.gradle of the app using the snippet from the webpage as follows
compile(group: 'asdf.asdf.utils', name: 'utilities', version: '2.0.0.0', ext: 'aar')
Android Studio doesn't show any errors. It compiles into an apk fine but when I run it, the app immediately crashes with java.lang.NoClassDefFoundError: com.google.gson.GsonBuilder
.
Shouldn't gradle automatically download gson and compile it into the apk as per the pom in the Artifactory repo? I am new to maven, android studio, gradle etc. I am used to developing in Eclipse ADT. I would appreciate any help.