0

I am trying to build a FBReader project http://fbreader.org/FBReaderJ, which has native code dependencies. With latest ADT and Android Studio v. 0.5.4 I am able to import eclipse project also with NDK. The project builds fine, altough I got exception at runtime

    java.lang.NoClassDefFoundError: org/geometerplus/fbreader/formats/PluginCollection
        at org.geometerplus.fbreader.book.BookCollection.getBookByFile(BookCollection.java:63)
        at org.geometerplus.android.fbreader.libraryService.LibraryService$LibraryImplementation.getBookByFile(LibraryService.java:174)
        at org.geometerplus.android.fbreader.libraryService.LibraryInterface$Stub.onTransact(LibraryInterface.java:103)
        at android.os.Binder.execTransact(Binder.java:367)
        at dalvik.system.NativeStart.run(Native Method)

When I try to build and run project from eclipse using ant, everything works fine. I did nothing else than import - build - run. Clean, rebuild, sync studio wont help. The class pointed in exception is not in any library module, it's in main module, but different package.

Any thoughts? Any help much appreciated!

Michal
  • 1,008
  • 1
  • 12
  • 16
  • Also I forgot to mention that this has nothing to do with native clases...I think. Class reffering from exception is simple Java class. – Michal Apr 11 '14 at 09:38

1 Answers1

0

Of course it has to do with NDK build! :) I overlooked that Android Studio did not include .so libraries during the import. Hope that will be fixed soon. Answer from JNI and Gradle in Android Studio did the trick.

    sourceSets.main {
    jni.srcDirs = []
    jniLibs.srcDir 'libs'
}

I include them in source tree (lib folder) and put native code into jni folder. Also worth mention first line indicating srcDirs = [] I already have Android.mk file that describe native sources for ndk build, so this line prevent Gradle for generating it's own.

Community
  • 1
  • 1
Michal
  • 1,008
  • 1
  • 12
  • 16