Android library and DropboxSync

Who can help me fix a bug in my Android project. I am doing synchronization with dropbox in my project, but when I try to start the application, I have errors: caused by: java.lang.UnsatisfiedLinkError: Library DropboxSync not found

09-02 12:56:55.367 1313-1313/? E/AndroidRuntime: Uncaught handler: thread main exiting due to uncaught exception 09-02 12:56:55.377 1313-1313/? E/AndroidRuntime: java.lang.ExceptionInInitializerError at com.dropbox.sync.android.CoreAccountManager.initNativeLib(CoreAccountManager.java:111) at com.dropbox.sync.android.CoreAccountManager.<init>(CoreAccountManager.java:91) at com.dropbox.sync.android.DbxAccountManager.getInstance(DbxAccountManager.java:132) at com.dropbox.sync.android.DbxAccountManager.getInstance(DbxAccountManager.java:100) at com.shvedchenko.skleroshop.MainActivity.onCreate(MainActivity.java:44) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) at android.app.ActivityThread.access$2200(ActivityThread.java:119) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4363) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ExceptionInInitializerError at com.dropbox.sync.android.NativeLib.<init>(NativeLib.java:33) at com.dropbox.sync.android.NativeLib.<clinit>(NativeLib.java:11) ... 18 more Caused by: java.lang.UnsatisfiedLinkError: Library DropboxSync not found at java.lang.Runtime.loadLibrary(Runtime.java:489) at java.lang.System.loadLibrary(System.java:557) at com.dropbox.sync.android.NativeHttp.<clinit>(NativeHttp.java:411) ... 20 more 

Line No. 44 - mDbxAcctMgr = DbxAccountManager.getInstance (getApplicationContext (), appKey, appSecret);

I do not understand what is wrong?

thanks!

0
source share
4 answers

This seems to be a common problem with native libraries and gradle. I found this answer so useful: Enable .so library in apk in android studio

Now part of my build.gradle file looks like this, and my application starts up successfully:

 dependencies { compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar') compile fileTree(dir: 'libs', include: '*.jar') } task nativeLibsToJar( type: Zip, description: 'create a jar archive of the native libs') { destinationDir file("$buildDir/native-libs") baseName 'native-libs' extension 'jar' from fileTree(dir: 'libs', include: '**/*.so') into 'lib/' } tasks.withType(Compile) { compileTask -> compileTask.dependsOn(nativeLibsToJar) } 
0
source

Here is my solution:

 dependencies { compile files('libs/dropbox-sync-sdk-android.jar') } android { tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> pkgTask.jniFolders = new HashSet<File>(); pkgTask.jniFolders.add(new File(projectDir, 'libs')); } } 

Place the 'libs' folder from Dropbox sdk at the same level with the 'build' and 'src' folders.

+1
source

It seems you missed the library for Dropbox (native part)

you can see that at the bottom of your stacktrace

  Caused by: java.lang.UnsatisfiedLinkError: Library DropboxSync not found at java.lang.Runtime.loadLibrary(Runtime.java:489) at java.lang.System.loadLibrary(System.java:557) at com.dropbox.sync.android.NativeHttp.<clinit>(NativeHttp.java:411) ... 20 more 

check library loading or documentation where you can get the missing library file

[UPDATE] . How to use custom libraries with android studio installation

Put your * .so files inside the libs folder next to the src folder

 task copyNativeLibs(type: Copy) { from(new File('libs')) { include '**/*.so' } into new File(buildDir, 'native-libs') } tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs } clean.dependsOn 'cleanCopyNativeLibs' tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> pkgTask.jniDir new File(buildDir, 'native-libs') } 
0
source

solution without copying data

Perhaps most of us developers do not like to copy data from one place to another ... So, here is a solution without copying .so files to your project:

 compile files('M:\\Dropbox\\SWDevelopment\\Libraries\\Android\\dropbox-android-sync-sdk-3.1.2\\libs\\dropbox-sync-sdk-android.jar') compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar') task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') { destinationDir file("$buildDir/native-libs") baseName 'native-libs' extension 'jar' from fileTree(dir: 'M:/Dropbox/SWDevelopment/Libraries/Android/dropbox-android-sync-sdk-3.1.2/libs', include: '**/*.so') into 'lib/' } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn(nativeLibsToJar) } 

Just copy 2 occurrences of my apc spc apc folder to your own ...

0
source

Source: https://habr.com/ru/post/1499997/


All Articles