jberkel / android-plugin

An sbt plugin for Android development in Scala
https://groups.google.com/forum/#!forum/scala-on-android
Other
476 stars 113 forks source link

Native Libraries are not included #179

Closed Marvin182 closed 11 years ago

Marvin182 commented 11 years ago

I tried building an Android app using the ZBar Android SDK, but failed with sbt (elipse works just fine), because they use native libraries which are not copied to the apk. I believe that proguard removes a little bit to much in my case, but I couldn't figure out how to tell it, that it should keep and include the library files.

@fxthomas: I also tried your testing branch, but it didn't work out much better. With compile I got a dex file which was big enough to have the 3 native libraries included, but the android app crashed anyway.

fxthomas commented 11 years ago
appamatto commented 11 years ago

Does proguard have anything to do with the native libraries? We have special handling for dependencies which are native libraries (only) but I'm not sure that the native libraries get copied if they are simply inside a JAR file.

Marvin182 commented 11 years ago

[info] ArrayBuffer(Attributed(C:\Users\Marvin\Dropbox\workspace\TicketChecker\lib\zbar.jar), Attributed(C:\Portables\and roid-sdk\sdk\platforms\android-16\android.jar), Attributed(C:\Portables\android-sdk\sdk\platforms\android-16\android.jar ), Attributed(C:\Portables\android-sdk\sdk\platforms\android-16\android.jar))

Marvin182 commented 11 years ago

I uploaded the project to https://github.com/Marvin182/TicketChecker

fxthomas commented 11 years ago

@appamatto, I don't think native libraries inside JARs are included either, but I could be wrong, I have never tested that a lot.

@Marvin182 : Actually, just put the .so files inside ./src/main/libs (so you'll have ./src/main/libs/armeabi/... and so on). The JARs stay inside ./lib/, and it works for me. It was probably done that way to be able to use the NDK more easily, but... that shouldn't be so hard for simple projects like yours. I'll look into it!

Marvin182 commented 11 years ago

wtf -.-
I spend hours on searching for a solution, but it was never mentioned that the libs should be in src/main/libs ...

Thank you! :)

fxthomas commented 11 years ago

Took me a while to guess as well.

For the record, when I tried running show native<TAB> after a while, it showed me a list of exactly one potential candidate setting, and then it didn't take me long to guess that natives-lib-path was where SBT looked for .so files... Could be handy next time you have an issue like that!

Anyway, this sucks, I think I'll try to change that to be the same as the JARs, plus it makes no sense (besides catering to old-style Ant Android projects) to put libs inside src/main, as I don't see any source in .so files!

(Added this to the wiki)