Android Studio + dropbox-android-sync-sdk-1.1.2

Can someone explain how I can enable the Dropbox SDK in Android Studio? On the Dropbox website, I found information for the Eclipse IDE. I tried to include it in Android Studio, but with no result. The IDE cannot find the com.dropbox.sync class.

/ ERROR when I want to create I make link mDbxAcctMgr = DbxAccountManager.getInstance (getApplicationContext (), appKey, appSecret); /

  09-02 12:38:46.297 1133-1133/? E/AndroidRuntime: Uncaught handler: thread main exiting due to uncaught exception 09-02 12:38:46.307 1133-1133/? 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.example.dropbox.MainActivity.onCreate(MainActivity.java:43) 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 
+4
source share
3 answers

I have never used Android Studio before, so I had to look for it ... these are good instructions for adding an external library to an Android Studio project: How do I add a library project in Android Studio?

After that, with the Dropbox Android Sync SDK, I nested the contents of the libs in the Android SDK into the libs in my Android project, and then added this line to build.gradle (inside dependencies ):

 compile files('libs/dropbox-sync-sdk-android.jar') 

It seemed to work for me. If you tried this and it didnโ€™t work (or if you tried something else), provide some details.

EDIT Paste my answer from Android and DropboxSync Library for completeness:

I found this SO answer useful: enable .so library in apk in android studio

Part of my build.gradle file now 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) } 
+5
source

The official solution did not work for me. And I notice "Compile" in tasks.withType (Compile) has an obsolete warning.

The following lines in build.gradle work:

 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.

+2
source

You have the official answer on the Dropbox Developer Blog:

https://www.dropbox.com/developers/blog/57/using-the-sync-api-with-android-studio

It's funny that a question interesting enough for the api developers answer is rated negatively ...

+1
source

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


All Articles