简体   繁体   中英

Building Android Library Project Using Jsoup Library

I have a android library project(say SampleLibProject which generates a jar in bin as samplelibproject.jar ) which uses Jsoup library to read href attribute from a tag. And In my android App, If I add reference of library using (Project Properties -> Android and browsing library project) App works OK without any issue as I dont require to copy Jsoup in my Android app libs .

But If I add samplelibproject.jar in libs of Android App without Jsoup library I get an Exception that java.lang.NoClassDefFoundError: org.jsoup.Jsoup .

So my question is how can I build SampleLibProject so that there will be no need of adding Jsoup jar in Android App?

As I am not going to distribute sources of LibProject (I will just give samplelibproject.jar to clients ) and don't want to force them to include jsoup library in there android project.

Thanks in advance.

I would look into using android studio unless you are married to eclipse It is one line to import this in the build.gradle for the app "compile 'org.jsoup:jsoup:1.8.1'". I am using this to strip html from incoming text into an app.

The current supported format for distributing android libraries without shipping the entire source code is called AAR. As far as I can tell this only works with Android Studio, but from the format itself it seems that you might be able to generate it manually. Take a look here: http://tools.android.com/tech-docs/new-build-system/aar-format

Adding Jsoup sources in my libproject solved my problem(Atleast for time being).

@gllowmas,@jucas Thanks for the suggestions though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM