1

I have an android library and want to distribute it like jar.

I create the demo project that shows how my library works and add gradle dependency from my library:

compile project(':my-library') 

Then I build the project, it works fine. Than I take jar file from my library (from build/intermediates/bundles/release - link), and put it to libs directory and replace the dependency with this:

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

But I was very surprised because the demo app did not work. I tried to clean, make jar more times, clear cache, test it on different Android versions from 4.0 till 6.0.1 but the same picture: it works if library is connected to sources, but does not work if library is connected like jar created from that sources.

My library is quite big, and I'm not sure what exactly goes wrong. In normal conditions it should load some javascript from server, run it and show some results in WebView, but in case of jar file I see only empty screen.

How is this possible?

4
  • Have you tried debugging your code? And the problem is only at runtime? You can compile and use the library in your code just fine? Commented Mar 6, 2016 at 13:53
  • @XaverKapeller I'm debugging now, but I believe it will takes few days. Yes, the problem in runtime. Not got you last question. Commented Mar 6, 2016 at 13:56
  • Do you have also the resources in your android library? Commented Mar 6, 2016 at 18:51
  • @GabrieleMariotti no, just java code. Commented Mar 6, 2016 at 19:30

1 Answer 1

0

I found an issue:

In my library I have dependency:

compile 'com.google.android.gms:play-services:8.4.0' 

And don't have it on my demo project.

And it hungs on this lines, inside library:

 Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(mContext); 

The solution is to add dependency on demo also, use some other method to get Google Advertising id.

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

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.