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?

Community
  • 1
  • 1
anber
  • 3,463
  • 6
  • 39
  • 68

1 Answers1

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.

anber
  • 3,463
  • 6
  • 39
  • 68