I am using Proguard in my android app to reduce the number of methods (see this). For that I have coded some lines in proguard-project.txt file. All the jars work well after the necessary commands. But when I try to integrate Video Chat part of Quickblox, they provide us a .so that I would have to integrate. So I just keep it in the libs\armeabi\libilbc-codec.so path as guided by them. Now the project runs well when I run it without Proguard, but when I compile it with Proguard, it gives me with following error:
11-21 18:18:19.171: E/AndroidRuntime(19825): FATAL EXCEPTION: Thread-34829
11-21 18:18:19.171: E/AndroidRuntime(19825): java.lang.ExceptionInInitializerError
11-21 18:18:19.171: E/AndroidRuntime(19825): at com.quickblox.videochat.core.objects.AudioRecorder$AudioRecorderRunnable.run(AudioRecorder.java:196)
11-21 18:18:19.171: E/AndroidRuntime(19825): at java.lang.Thread.run(Thread.java:864)
11-21 18:18:19.171: E/AndroidRuntime(19825): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load ilbc-codec: findLibrary returned null
11-21 18:18:19.171: E/AndroidRuntime(19825): at java.lang.Runtime.loadLibrary(Runtime.java:365)
11-21 18:18:19.171: E/AndroidRuntime(19825): at java.lang.System.loadLibrary(System.java:535)
11-21 18:18:19.171: E/AndroidRuntime(19825): at com.googlecode.androidilbc.Codec.<init>(Codec.java:16)
11-21 18:18:19.171: E/AndroidRuntime(19825): at com.googlecode.androidilbc.Codec.<clinit>(Codec.java:5)
11-21 18:18:19.171: E/AndroidRuntime(19825): ... 2 more
11-21 18:18:19.281: E/copybit(19825): Error opening frame buffer errno=13 (Permission denied)
I am very noob to using Proguard as well as NDK, so can anyone guide me as how can I overcome this issue? I have added Native support by Right clicking on project -> Android Tool -> Add Native Support.. and selected the .so file I have been using. So can anyone suggest any solution or the lines that I would have to write to this .so file to work ?
Thanks in Advance.
EDIT:
After following #ph0b's comment, I tried following steps:
I have removed BDK supprot from the app following this tutorial and also unzipped the apk as per his steps and I am getting my "libilbc-codec.so" library under "/lib/armeabi". But still getting the below error. So what might be wrong now ??
11-24 12:12:29.045: E/AndroidRuntime(6049): FATAL EXCEPTION: Thread-455
11-24 12:12:29.045: E/AndroidRuntime(6049): Process: com.hypersquare, PID: 6049
11-24 12:12:29.045: E/AndroidRuntime(6049): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.hypersquare-1/base.apk"],nativeLibraryDirectories=[/data/app/com.hypersquare-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libilbc-codec.so"
11-24 12:12:29.045: E/AndroidRuntime(6049): at java.lang.Runtime.loadLibrary(Runtime.java:366)
11-24 12:12:29.045: E/AndroidRuntime(6049): at java.lang.System.loadLibrary(System.java:989)
11-24 12:12:29.045: E/AndroidRuntime(6049): at com.googlecode.androidilbc.Codec.<init>(Codec.java:16)
11-24 12:12:29.045: E/AndroidRuntime(6049): at com.googlecode.androidilbc.Codec.<clinit>(Codec.java:5)
11-24 12:12:29.045: E/AndroidRuntime(6049): at com.quickblox.videochat.core.objects.AudioRecorder$AudioRecorderRunnable.run(AudioRecorder.java:196)
11-24 12:12:29.045: E/AndroidRuntime(6049): at java.lang.Thread.run(Thread.java:818)
Proguard shouldn't remove .so files, I guess your issue comes from something else.
When you use "add native support" from eclipse, eclipse creates an empty ndk library project (a jni folder with empty sources and a sample Makefile).
So when you build your app, eclipse empties libs/*/ folders, then build and install the newly created library here.
If you don't use the NDK yourself (not compiling any sources with it), you should remove the jni folder and its content from your project, and put the .so files you need to be packaged into your apk, directly inside libs/(armeabi|x86|...) folders (btw, it's jniLibs instead of libs when using Android Studio).
In order to check what .so files are getting packaged into your app, you can open your APK as a zip file and look under the lib/(armeabi|x86|...) folders.
Related
I cloned this project and and copied the .so files to my project's jniLibs folder.
After that, it looked like this:
However, when I tried using the library it throws:
09-18 10:22:53.861 18439-19193/com.mopo.audiofingerprinter W/linker: libACRCloudExtrTool.so: unused DT entry: type 0x6ffffffe arg 0x4718
09-18 10:22:53.861 18439-19193/com.mopo.audiofingerprinter W/linker: libACRCloudExtrTool.so: unused DT entry: type 0x6fffffff arg 0x2
09-18 10:22:53.871 18439-19193/com.mopo.audiofingerprinter E/art: No implementation found for void com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.native_init() (tried Java_com_mopo_audiofingerprinter_tageditor_ACRCloudExtrTool_native_1init and Java_com_mopo_audiofingerprinter_tageditor_ACRCloudExtrTool_native_1init__)
09-18 10:22:53.881 18439-19193/com.mopo.audiofingerprinter E/UncaughtException: java.lang.UnsatisfiedLinkError: No implementation found for void com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.native_init() (tried Java_com_mopo_audiofingerprinter_tageditor_ACRCloudExtrTool_native_1init and Java_com_mopo_audiofingerprinter_tageditor_ACRCloudExtrTool_native_1init__)
at com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.native_init(Native Method)
at com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.<clinit>(ACRCloudExtrTool.java:57)
at com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.createFingerprintByFile(ACRCloudExtrTool.java:0)
at com.mopo.audiofingerprinter.tageditor.ACRCloudRecognizer.recognizeByFile(ACRCloudRecognizer.java:129)
at com.mopo.audiofingerprinter.tageditor.TestActivity$RecThread.run(TestActivity.java:84)
09-18 10:22:54.132 18439-19193/com.mopo.audiofingerprinter E/AndroidRuntime: FATAL EXCEPTION: Thread-51298
Process: com.mopo.audiofingerprinter, PID: 18439
java.lang.UnsatisfiedLinkError: No implementation found for void com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.native_init() (tried Java_com_mopo_audiofingerprinter_tageditor_ACRCloudExtrTool_native_1init and Java_com_mopo_audiofingerprinter_tageditor_ACRCloudExtrTool_native_1init__)
at com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.native_init(Native Method)
at com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.<clinit>(ACRCloudExtrTool.java:57)
at com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.createFingerprintByFile(ACRCloudExtrTool.java:0)
at com.mopo.audiofingerprinter.tageditor.ACRCloudRecognizer.recognizeByFile(ACRCloudRecognizer.java:129)
at com.mopo.audiofingerprinter.tageditor.TestActivity$RecThread.run(TestActivity.java:84)
The weird thing, is that the compiled project I cloned is working without errors. I have even attempted copying the classes from the demo and still it didn't work.
EDIT
After implementing Divy Soni's answer, the jniLibs folder disappeared entirely. And when I built the app it crashed with:
`09-18 11:21:46.848 26158-26798/com.mopo.audiofingerprinter E/UncaughtException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.mopo.audiofingerprinter-1/base.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.mopo.audiofingerprinter-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.mopo.audiofingerprinter-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libACRCloudExtrTool.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:988)
at com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.<clinit>(ACRCloudExtrTool.java:56)
at com.mopo.audiofingerprinter.tageditor.ACRCloudExtrTool.createFingerprintByFile(ACRCloudExtrTool.java:0)
at com.mopo.audiofingerprinter.tageditor.ACRCloudRecognizer.recognizeByFile(ACRCloudRecognizer.java:129)
at com.mopo.audiofingerprinter.tageditor.TestActivity$RecThread.run(TestActivity.java:84)`
EDIT2
Please note that the feaures I am using libACRCloudEngine.so is working perfectly. So it's libACRCloudExtrTool.so that is the problem here.
put this line in app build.gradle,it represent the path of .so files.
android {
.
.
sourceSets {
main {
jniLibs.srcDirs = ['jniLibs']
}
}
}
I succesfully compiled PJSIP library for Android. Sample project works without any problems when I build for default architecture armeabi. Now I tried to compile library for arch such as armeabi-v7a and arm64-v8a. Unfortunately when I add libraries to project in appropriate folders (jnLibs/armeabi-v7a and jniLibs/arm64-v8a) application is not starting...
To setup build for different archs I use this command:
NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags
I have this error on app launch:
07-04 12:28:46.079 15317-15317/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.futuremind.omili, PID: 15317
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "getifaddrs" referenced by "/data/app/com.futuremind.omili-1/lib/arm/libpjsua2.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:372)
at java.lang.System.loadLibrary(System.java:1076)
at com.futuremind.omili.MyApp.<clinit>(MyApp.java:293)
at com.futuremind.omili.MainActivity.onCreate(MainActivity.java:87)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Thanks for any help! :)
I was able to fix this error by updating the AndroidManifest.xml in "pjsip-apps/src/swig/java/android/app/src/main" to match my android target -- in my case to "23". Then "make clean" and another "make" in "pjsip-apps/src/swig", and rebuilding my app.
I am having an (Android Studio - Gradle) Cordova (3.6.4) project.
In my app there can be a list of pdf files which should be shown with mupdf.
But I always get the following error message:
06-10 15:04:38.365 5940-5940/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: de.dil.DSM, PID: 5940
java.lang.UnsatisfiedLinkError: Couldn't load mupdf from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/de.dil.DSM-2.apk"],nativeLibraryDirectories=[/data/app-lib/de.dil.DSM-2, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.artifex.mupdfdemo.MuPDFCore.<clinit>(MuPDFCore.java:14)
at de.dil.DSM.DSM.loadFile(DSM.java:216)
at de.dil.DSM.xviewer$6.run(xviewer.java:102)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
The java files from mupdf seems to be correctly imported.
It seems to be, that it is "just" the "libmupdf.so" which isn't correctly imported.
The libmupdf.so files are in the following directories:
libs/armeabi/libmupdf.so
libs/armeabi-v7a/libmupdf.so
There is also a c mupdf file here: jni/mupdf.c
Is there anything which I especially need to configure in the settings.gradle or in the build.gradle?
Thanks ahead!!!!
Put your .so files in a jniLibs folder
>src
>main
>jniLibs
>armeabi
|libmupdf.so
>armeabi-v7a
|libmupdf.so
The solution was to add this:
jniLibs.srcDirs = ['libs']
To the existing sourceSets in the build.gradle!
After updating to new version GooglePlayGamesPlugin-0.9.10 for unity, I'm facing a problem.
Logcat:
11-21 16:35:22.759: D/dalvikvm(1582): Trying to load lib /data/data/com.Dark.QuizRacer/lib/libgpg.so 0xa6a82f28
11-21 16:35:22.763: D/houdini(1582): [1597] Open Native Library /data/data/com.Dark.QuizRacer/lib/libgpg.so failed.
11-21 16:35:22.763: D/dalvikvm(1582): Trying to load lib /data/data/com.Dark.QuizRacer/lib/libgpg.so 0xa6a82f28
11-21 16:35:22.763: D/houdini(1582): [1597] Open Native Library /data/data/com.Dark.QuizRacer/lib/libgpg.so failed.
11-21 16:35:22.763: E/Unity(1582): Unable to find gpg
11-21 16:35:22.771: D/dalvikvm(1582): Trying to load lib /data/data/com.Dark.QuizRacer/lib/libgpg.so 0xa6a82f28
11-21 16:35:22.771: D/houdini(1582): [1597] Open Native Library /data/data/com.Dark.QuizRacer/lib/libgpg.so failed.
11-21 16:35:22.771: D/dalvikvm(1582): Trying to load lib /data/data/com.Dark.QuizRacer/lib/libgpg.so 0xa6a82f28
11-21 16:35:22.775: D/houdini(1582): [1597] Open Native Library /data/data/com.Dark.QuizRacer/lib/libgpg.so failed.
11-21 16:35:22.775: E/Unity(1582): Unable to find gpg
11-21 16:35:22.867: I/Unity(1582): DllNotFoundException: gpg
Is there any possible solution?
Thanks in advance for any help.
This is a known bug. The current workaround ist to use static compiled libgpg. See here at github
I have an android project with a QR scan activity. I use the ZBar library for this: http://sourceforge.net/projects/zbar/files/AndroidSDK/
If the project is built on a PC or Mac with exlipse, the app works fine.
If it's build by jenkins (same source from git) the app crashes.
The Exception I get is:
at controller.gui.activity.QRScanActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoSuchFieldError: no field with name='peer' signature='J' in class Lnet/sourceforge/zbar/ImageScanner;
at net.sourceforge.zbar.ImageScanner.init(Native Method)
at net.sourceforge.zbar.ImageScanner.<clinit>(Unknown Source)
... 16 more
I used the demo app for a base.
Is this a Jenkins config problem?
The Zbar library is not just a jar file, it's a C library with jni. So I have a jar file and 3 folders (for different architectures I think) and they have a libiconv.so and a libzbarjni.so files.
Add -keep class net.sourceforge.zbar.** { *; } to your proguard config file
I Dont know if you already figured it out, but this is a proguard issue. Seems your JNI classes are not being obfuscated correctly. You might need to change your proguard config to skip ZBar files.