1

I have implemented a Library Project called "proximity" in Android Studio and generated an ".aar". This aar I've added to a new test project as an module, as stated here:https://stackoverflow.com/a/24894387/2791503 Furthermore I included the module as an dependency with the transitive flag, as it has been proposed here: https://stackoverflow.com/a/25730092/2791503 This is may gradle File for the new TestProject:

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   testCompile 'junit:junit:4.12'
   compile 'com.android.support:appcompat-v7:23.1.1'
   compile(project(':proximity')) {
    transitive=true
}

Still when I launch the App it tells me that it can not find a class of the Google Location API, which is a dependency of my library module.

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/GoogleApiClient$Builder;

How can I force gradle to include those transitive dependencies of my library module?

EDIT: Here is the gradle build file of the original library project:

dependencies {
   //integration tests
   androidTestCompile 'com.android.support.test:runner:0.4.1'
   // Set this dependency to use JUnit 4 rules
   androidTestCompile 'com.android.support.test:rules:0.4.1'
   // Set this dependency to build and run Espresso tests
   androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
   // Set this dependency to build and run UI Automator tests
   androidTestCompile 'com.android.support.test.uiautomator:uiautomator-  v18:2.1.2'
   androidTestCompile 'com.android.support:support-annotations:23.1.1'

   //local unit testing
   testCompile 'junit:junit:4.1'

   compile fileTree(include: ['*.jar'], dir: 'libs')
   compile 'com.android.support:appcompat-v7:23.1.1'
   //estimote sdk
   compile 'com.estimote:sdk:0.9.4@aar'
   //google location api(GPS)
   compile 'com.google.android.gms:play-services-location:8.4.0'
   //Google Guave Java Util
   compile 'com.google.guava:guava:18.0'
   //custom BeSpoon library for android
   compile project(':bespoonlibrary')
}

And this is how the gradle build file looks after importing the library as a module referencing the aar:

configurations.create("default")
artifacts.add("default", file('app-release.aar'))
Community
  • 1
  • 1
Juri Adam
  • 569
  • 6
  • 21

1 Answers1

0

So I found a solution which works for me, but still this I not what I was hoping for...so let me know if anyone has a better solution. Anyway this might help someone: I have two libraries, one external library, the library project itself and one internal libaray which is a dependency of the external library. Furthermore Each library has its own dependencies for example the internal library references google-location-service.

I tried gradlew assemble which generates a *.aar file of the external library. But all there was in the aar was the external library, but without the internal library and all the other dependencies. This discussion says there is no way to handle this so far: How to export AAR including its dependencies?

There is no sense using this aar without all the dependences...so I had to find another way. In the Android TestProject where the external library shall be included click File->Import Module->"Select the external library"->Finishand all your dependencies are there, including the internal library.

Community
  • 1
  • 1
Juri Adam
  • 569
  • 6
  • 21