2

I have an Android library on jitpack.io and let devs add my library but just adding the dependency. But what I've noticed is that if this dependency is added, my library classes have to be decompiled to view the code.

So for example, I have a class in my library called ViewStack. When I try to go to the class file to view the source code, it's a decompiled version of the .class file. And thus, all my documentation is not there.

How can I make it so the code is entirely viewable (no decompiling necessary) and my docs come through even if the user just is adding the library as a gradle dependency?

This is the library if curious: https://github.com/JayyyR/PancakesOnPlates

jacosta
  • 349
  • 2
  • 5
  • 17
  • Would the answers from http://stackoverflow.com/questions/11474729/how-to-build-sources-jar-with-gradle help? – JulianHarty Jun 02 '16 at 09:22
  • Not sure that is what I'm looking for. I'm not looking to generate a jar. I just want the source code to be visible. Is this possible? I'm almost certain it is because when I add a dependency in gradle for, for example, the recyclerview library - all the code and docs are visible to me even though I didn't add a jar – jacosta Jun 02 '16 at 19:44
  • Since you have an example jar that behaves as you'd like your to do, how about unzipping it (change the file extension from jar to zip or simply brute-force the unzip) and see what it contains in terms of layout and contents. Then you should be able to create something with the same structure. I'm still learning the basics of Gradle so can't give you a concrete answer (yet) sorry... – JulianHarty Jun 02 '16 at 20:23
  • No worries, thanks for the help – jacosta Jun 02 '16 at 20:43

1 Answers1

0

It depends if you're publishing the library as an aar or a jar.

For aar files it doesn't seem to be possible at the moment How to publish Android .aar sources to make Android Studio automatically find them?

For jar you just need to publish the -sources.jar file along your main jar.

Community
  • 1
  • 1
Andrejs
  • 26,885
  • 12
  • 107
  • 96
  • Forgive me for the dumb question, but how do I know if its published as a jar or an aar? All I did with jitpack was just provide my github repo address and made a release on github – jacosta Jun 03 '16 at 14:25
  • By default android libraries are published as an .aar but you can publish a .jar instead https://github.com/jitpack/android-example/blob/master/library/build.gradle#L47-L54 – Andrejs Jun 07 '16 at 07:53