Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using library in Android Studio - empty classes.jar

I added the following dependency to to build.gradle file in Android Studio and resync-ed the project successfully:

compile 'se.emilsjolander:stickylistheaders:2.1.3'

However I was unable to use any of the class in this library. Feeling strange I opened the source tree and see if there's anything wrong. I noticed the following:

Empty classes.jar

You can see Android Studio can found the available classes for other downloaded archives, but not the one I mentioned in this question. The classes.jar file is reported empty.

I tried adding an older version of the stickylistheaders library (2.1.3). Still an empty classes.jar.

When I start this question I found a similar post here. But the author of that post tried to include the downloaded project in settings.gradle, and he finally managed to include the library through the "compile" directive. My problem is that I AM using the "compile" directive, but the downloaded archive has a "empty" classes.jar. I also tried adding the library mentioned in that question (i.e. 'se.emilsjolander:StickyScrollViewItems:1.0.0'). Also an empty classes.jar.

Some notes:

  • The actual classes.jar file found in build/exploded-bundles is not empty.
  • I tried cleaning the project. I suppose this will cause all dependencies be removed and re-downloaded. However, after that, Android Studio still cannot spot any class in stickylistheaders' classes.jar.
  • So far, this problem only exists for se.emilsjolander's libraries. Strangely, the answerer of this post1 posted a screenshot showing that he does see a non-empty classes.jar.

Update:

  • I also tried deleting .gradle's cache directory in my profile directory, clean the project and rebuild again. No luck.
  • I can unzip the classes.jar in question. Looks like the file isn't corrupt.

Anyone knows what's wrong here? Thanks.

like image 397
Edmund Tam Avatar asked Dec 03 '25 08:12

Edmund Tam


1 Answers

I think I have found the cause: it should be a bug in Android Studio.

https://code.google.com/p/android/issues/detail?id=64008

In fact, the code can build and run despite seeing errors in Android Studio. So it is obviously an issue with Android Studio.

Update 27 Jan: It should have been resolved in Android 0.4.3. As from the release notes:

Fixed a bug around library syncing (where library dependency classes and resources could suddenly not be found by the IDE)

like image 89
Edmund Tam Avatar answered Dec 06 '25 00:12

Edmund Tam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!