1

I am using Android Studio 0.8.2 and in my project I have one Android module and one Java only module. The java only module depends on a external library. I have tried adding it in the libs dir of the project:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

And using maven repositories:

repositories {
    mavenCentral()
}

dependencies {
    compile 'net.sf.kxml:kxml2:2.3.0+'
}

Both systems allows compilation but the library is not included on final jar. I have unzipped the jar and the classes are not there!

Exception in thread "main" java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException

A Gradle sync shows this warning message:

"A top-level `dependencies` block should only appear in build files that correspond to a module" 

Any idea? Thanks advanced.

1

1 Answer 1

1

Looks like you are not declaring dependencies in build.gradle in app folder, but in the main roof of project? Am I right? You should compare declaring dependencies with other projects like hmm on github. Example: https://github.com/loopj/android-async-http/blob/master/sample/build.gradle (this is build.gradle file in module project, if you go up to root, in build.gradle file there is not declaring not connected to gradle depenncies). Read carefuly the comments and warnings.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. I have no app folder but two module folders, the dependecies I am declaring for this module are in the java only module folder build.gradle. The root build.gradle does not have dependencies and the Android module add correctly the dependencies defines in its own folder build.gradle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.