5

I am making a library project for a vendor and it needs Android Volley as a dependency. I have used this Create aar file in Android Studio to create the .aar file and to include this in a test project I am using this Adding local .aar files to Gradle build using "flatDirs" is not working. The library is linked fine and there are no errors in the project compilation. But at runtime the test application crashes saying it cannot find Volley

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/android/volley/toolbox/Volley;
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.volley.toolbox.Volley" on path: DexPathList[[zip file "/data/app/in.gridsync.acttest-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

My Gradle file for the library project is like this

    apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.mcxiaoke.volley:library:1.0.19'
}

and in the test project the gradle is this

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "in.gridsync.acttest"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile project(':openapp-library')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
}

I assumed, when the .aar package was created, it'd use and include the dependency it has on Volley library. Can someone please throw some light on this?

12
  • mate why not just add Volley from the depeneices tab on Project Structaure? Commented Dec 25, 2015 at 17:57
  • add testCompile 'com.mcxiaoke.volley:library:1.0.19' Commented Dec 25, 2015 at 19:17
  • 1
    @ItzikSamara, I dont want my vendor to add anything except for the aar package. That makes sense right? Because if I use some other library in the future, I dont want him to change his application code no more than just replacing the new .aar package which I give Commented Dec 26, 2015 at 6:39
  • How did you solve this, I face the same problem! Commented Feb 27, 2016 at 17:24
  • did you solve this ? Commented Jun 8, 2016 at 15:29

2 Answers 2

1

Far as I know, you must add "@aar" for the .aar libraries. Also the jar file isn't required, it downloads that by itself. Try this:

compile 'com.mcxiaoke.volley:library:1.0.19@aar'
Sign up to request clarification or add additional context in comments.

1 Comment

I tried his just now, this isn't working. The .aar doesn't still include the volley library in itself.
-1

One alternative solution is to place the dependent libraries as static jar file(s) in the "libs" folder of your project, instead of using gradle dependency. When generating aar file, the jar files under libs folder will be included in the aar.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.