Buck: couldn't find "libjni.so

Created on 12 Feb 2017  路  14Comments  路  Source: facebook/buck

Hey guys

I did all the steps on the Getting Started
But when I try to install the app I get this error. Probably something wrong on my machine. How do I fix it?

02-12 15:49:37.105: E/ERROR(4775): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.facebook.buck.demo-1/base.apk"],nativeLibraryDirectories=[/data/app/com.facebook.buck.demo-1/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libjni.so" 02-12 15:49:37.105: E/ERROR(4775): at com.facebook.buck.demo.Hello.<init>(Hello.java:17) 02-12 15:49:37.105: E/ERROR(4775): at com.facebook.buck.demo.App.onCreate(App.java:24)

Most helpful comment

Awesome, man! It works! I just had to execute again:

$ buck kill && rm -rf buck-out
$ buck build demo_app_android

Thanks a lot. This error was causing me headache for months

All 14 comments

I'm getting exactly the same error. This is happening after running the command
buck install --run demo_app_android

Then, the following is shown in console

Installing apk on emulator-5554 (null).
[-] PROCESSING BUCK FILES...FINISHED 0.0s [100%] 馃悓  File removed
[-] DOWNLOADING... (0.00 B/S AVG, TOTAL: 0.00 B, 0 Artifacts)
[-] BUILDING...FINISHED 0.8s [100%] (1/1 JOBS, 1 UPDATED, 0 [0.0%] CACHE MISS)
[+] INSTALLING...2.1s
Successfully ran install apk //android:demo-app on 1 device(s)
Starting activity com.facebook.buck.demo/.App...
Successfully ran start activity on 1 device(s)

Finally, the device shows a message saying Buck Demo App has stopped
The app is successfully installed as I can see it on the apps list but it's not working

Device specs:

  • Native Android Emulator (also, ran it into a real device with same result)
  • Nexus 6 API 25

My computer:

  • MacBook pro mid 2012

Same error here after building successfully and installing successfully.

Nexus 5 phone with Android 6.0.1

same here, sample won't run

meh, too complicated, gave up

Can you show the content of the APK?

$ unzip -l buck-out/gen/android/demo-app.apk

screen shot 2017-06-15 at 4 05 45 pm

Looks like your apk is missing libs:

$ unzip -l buck-out/gen/android/demo-app.apk
Archive:  buck-out/gen/android/demo-app.apk
  Length      Date    Time    Name
---------  ---------- -----   ----
     1400  02-01-1985 00:00   AndroidManifest.xml
     9348  02-01-1985 00:00   res/drawable-xxhdpi-v4/buck.png
      848  02-01-1985 00:00   res/layout/hello.xml
     1196  02-01-1985 00:00   resources.arsc
     3536  02-01-1985 00:00   classes.dex
     5224  02-01-1985 00:00   lib/armeabi/libcommon_hello.so
   800388  02-01-1985 00:00   lib/armeabi/libgnustl_shared.so
     5224  02-01-1985 00:00   lib/armeabi/libjni.so
     5236  02-01-1985 00:00   lib/armeabi-v7a/libcommon_hello.so
   796300  02-01-1985 00:00   lib/armeabi-v7a/libgnustl_shared.so
     5248  02-01-1985 00:00   lib/armeabi-v7a/libjni.so
     5180  02-01-1985 00:00   lib/x86/libcommon_hello.so
   988820  02-01-1985 00:00   lib/x86/libgnustl_shared.so
     5180  02-01-1985 00:00   lib/x86/libjni.so
     1135  02-01-1985 00:00   META-INF/MANIFEST.MF
     1188  02-01-1985 00:00   META-INF/CERT.SF
     1447  02-01-1985 00:00   META-INF/CERT.RSA
---------                     -------
  2636898                     17 files

Can you remove buck-out, rebuild apk and attach the log, please?

$ buck kill && rm -rf buck-out
$ buck build demo_app_android

Log should be in buck-out/log/buck-0.log.

I have to send it as .txt because .log is not accepted in GitHub

buck-0.txt

Ok, it looks like you don't have Android NDK installed.

You need to install Android NDK from here (version 10e) and set ANDROID_NDK_REPOSITORY to the location of the unpacked NDK (see buckconfig section for more info).

For example, if you unpack NDK to ~/tmp/ndk (so that there is a directory ~/tmp/ndk/android-ndk-r10e), you need to set ANDROID_NDK_REPOSITORY to ~/tmp/ndk.

From buck side, we need to update the documentation and not allow to build an APK without NDK.

Awesome, man! It works! I just had to execute again:

$ buck kill && rm -rf buck-out
$ buck build demo_app_android

Thanks a lot. This error was causing me headache for months

Updated docs in https://github.com/facebook/buck/commit/d38de122a72ba1ac1861c46226280c8648331197 and add a check to prevent building APKs when there is native code and no native platforms are present in https://github.com/facebook/buck/commit/28b232de738039bc0c410d8e6a3a7ebeefce8b26.

@styurin
the same problem, after installing ANDROID NDK and setting ANDROID_NDK_REPOSITORY to the path,
still no libjni.so generated.

when building the libjni.so it reports:

cross-platform-scale-2015-demo$ buck build //android/cxx:jni
Using watchman.
android/cxx/Hello.cpp:9:10: fatal error: 'jni.h' file not found

include

     ^

1 error generated.
BUILD FAILED: //android/cxx:jni#compile-Hello.cpp.o11bd3722,default failed with exit code 1:
c++ preprocess_and_compile
[-] PROCESSING BUCK FILES...FINISHED 0.3s [100%] 馃惓 New buck daemon
[-] DOWNLOADING... (0.00 B/S AVG, TOTAL: 0.00 B, 0 Artifacts)

[-] BUILDING...FINISHED 2.9s [100%] (4/4 JOBS, 4 UPDATED, 1 [25.0%] CACHE MISS)

seems buck won't search include-path in the ndk platform such as $ANDROID_NDK_REPOSITORY/platforms/android-21/arch-arm/usr/include
how to set the config for building this demo?

I've also tried:
$ buck kill && rm -rf buck-out
$ buck build demo_app_android
but still get no libjni.so
buck0_buildlog.txt

@RimingChen this is a separate problem, please, create a new issue

Was this page helpful?
0 / 5 - 0 ratings