2

I've searched everywhere I could for a solution to my problem an I couldn't find one, so I hope there's someone outhere who can help me.

I have a .jar library that I want to include into my project, I've followed a fews guides I found, but no one has worked for me so far, despite the fact that I can compile and generate my APK.

After installing the APK and launching the app, when a class member is called (the one from the library I want to import), my app crashes, and logcat gave me this :

Could not find class 'net.rdrei.android.dirchooser.DirectoryChooserActivity', referenced from method com.azsde.myApp.Settings$1.onPreferenceClick 

I then decompiled my apk because I was curious to see if the class has been included or not, and I found that it has not be included in my apk, here's a the result of a tree command listing my files:

http://pastebin.com/wcdK37FM

Here are my Java Build Path settings:

What did I do wrong and why isn't my library included in my APK?

1 Answer 1

1

Adding the JAR to your project's build path yourself as if it were a plain Java project will not work.

You add libraries to an Android project by copying the JAR to the libs folder at the root of your project (if the folder does not exist, then create it); ADT will then automatically add it to your build path and set up your project to bring the JAR into your APK.

You can learn more here http://tools.android.com/recent/dealingwithdependenciesinandroidprojects

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

3 Comments

Unfortunatly this doesn't work either :( I'm starting to wonder if my .jar is correct ... I imported the this git : github.com/passy/Android-DirectoryChooser into Android Studio and made a .jar out of it Is it correct ?
Android Studio is in alpha. I would stay away from it for now and stick to Eclipse. Maybe Android Studio is causing your issue.
Android Studio was indeed causing the issue, after strugling for a few minutes to understand how gradle was working, I compiled manually ( command prompt) and got a library that was working this time, it has been successfully included into my apk. Thank you very much !

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.