After long fight with building project i stuck on launching android activity
logcat output:
I/Unity (20479): Welcome on Android border
I/Unity (20479): AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/testapp/androidplugin/app/SplashScreen;
I/Unity (20479): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/testapp/androidplugin/app/SplashScreen;
I/Unity (20479): at com.testapp.androidplugin.app.UnityBinder.foo(UnityBinder.java:16)
I/Unity (20479): at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
I/Unity (20479): at com.unity3d.player.UnityPlayer.a(Unknown Source)
I/Unity (20479): at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
I/Unity (20479): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.testapp.androidplugin.app.SplashScreen" on path: DexPathList[[zip file "/mnt/asec/com.testapp.androidplugin.app-2/base.apk"],nativeLibraryDirectories=[/mnt/asec/com.testapp.androidplugin.app-2/lib/arm, /system/lib, /vendor/lib, sy
stem/vendor/lib, system/vendor/lib/egl, system/lib/hw]]
I/Unity (20479): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
I/Unity (20479): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
I/Unity (20479): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
First line is from Java class, so something happen...
UnityBinder.class
public static void foo(Activity activity) {
Log.i("Unity", "Welcome on Android border");
Intent myIntent = new Intent(activity, SplashScreen.class);
activity.startActivity(myIntent);
}
both classes are in the same package, I event tried with providing full path to package, but same result
if (GUI.Button(new Rect(200, 200, 400, 400), "Start"))
{
var androidJC = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var jo = androidJC.GetStatic<AndroidJavaObject>("currentActivity");
var jc = new AndroidJavaClass("com.testapp.androidplugin.app.UnityBinder");
jc.CallStatic("foo", jo);
}
SplashScreen is extended by AppCompatActivity
I used Java decompiler to look at files structure, and SplashScreen class exists there
In Plugins -> Android directory I have appcompat-v7-23.1.1.aar, design-23.1.1.aar, classes (which is from my unpacked *.aar android module), rest and assets folder.
I'm using unity 5.3
I have managed to do it. I copied appcompat-v7-25.3.1.aar & support-v4-25.3.1.aar to my Assets folder but it didn't work. Then I switched to Gradle build system in Unity and added following lines under dependencies.
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
It should like this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
**DEPS**}
Related
I have a project (Java application with a main) that runs fine from within Eclipse but when I export it to a (packed) runnable Jar and try to launch it from the command line with java -jar I get the following error message:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: com/github/javafaker/Faker
at jultävlingar2020.Jultävlingar2020.useChrome(Jultävlingar2020.java:154)
at jultävlingar2020.Jultävlingar2020.main(Jultävlingar2020.java:57)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.github.javafaker.Faker
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 7 more
There seems to be a problem with the inclusion of javafaker but using it works fine within Eclipse.
The project is Gradle-based and in my Project and External dependencies-folder I have javafaker-1.0.2.jar.
My build.gradle looks like this:
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:28.2-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
// Selenium
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
// Javafaker
implementation 'com.github.javafaker:javafaker:1.0.2'
}
How do I fix this?
I know this question may be duplicate but I have tried many solutions but I am unable to make my app work. It should be noted that I have enabled Multidex but still getting below error. I am creating a react native app.
FATAL EXCEPTION: main
Process: com.xxxxxx.yyyyyyyy, PID: 3978
java.lang.NoClassDefFoundError: com.google.android.gms.common.internal.zzbo
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5049)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4623)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4563)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5333)
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:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
If you are developing a react native application and above error came , just make sure that all of your dependencies's Gradle are using same version of firebase servces and play service base.
For example :- my app level gradle file contains
compile "com.google.android.gms:play-services-base:11.4.0"
compile "com.google.firebase:firebase-core:11.4.0"
compile "com.google.firebase:firebase-messaging:11.4.0"
compile "com.google.firebase:firebase-analytics:11.4.0"
compile "com.google.firebase:firebase-crash:11.4.0"
compile "com.google.firebase:firebase-ads:11.4.0"
and one react-native library is using
compile "com.google.android.gms:play-services-base:11.8.0"
and other one library is using
compile "com.google.android.gms:play-services-base:+"
so what i did , i changed all services version to 11.8.0.
BTW you can see gradles of all libraries or dependencies when you open your react-native-project/android folder in Android studio
I hope this will solve your issue
After moving my project to another computer, when trying to run the code (The exact same working code from the first computer), the application crashes.
This is the error in the console:
05-28 21:33:35.502 5021-5021/com.dean.booktown E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dean.booktown, PID: 5021
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.dean.booktown-1/base.apk", zip file "/data/app/com.dean.booktown-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.dean.booktown-1/split_lib_slice_4_apk.apk"],nativeLibraryDirectories=[/data/app/com.dean.booktown-1/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5244)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4836)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4776)
at android.app.ActivityThread.access$1600(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5525)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.dean.booktown-1/base.apk", zip file "/data/app/com.dean.booktown-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.dean.booktown-1/split_lib_slice_4_apk.apk"],nativeLibraryDirectories=[/data/app/com.dean.booktown-1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.installProvider(ActivityThread.java:5229)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4836)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4776)
at android.app.ActivityThread.access$1600(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5525)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Suppressed: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
I searched for other people with the same problem, and most answers were about not compiling play-services as a whole but only the parts needed, but I already had it that way
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0" /* TODO: Check 25.0.3 */
/* Before update - 24.0.2 */
defaultConfig {
applicationId "com.dean.booktown"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "Beta v0.8.6 'Ready'"
/* To enable Jack Toolchain - required for Java 8 */
/* jackOptions {
enabled true
} */
}
/* To enable Java 8 */
/* compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
} */
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0' /* Error? TODO: Check 25.3.1 */
compile 'com.google.android.gms:play-services-ads:10.2.6' /* AdMob */
compile 'com.github.bumptech.glide:glide:4.0.0-RC0' /* Glide - Loads lightweight images */
compile 'com.android.support:support-v4:23.4.0' /* TODO: Check 25.3.1 */
compile 'com.google.android.gms:play-services-location:10.2.6' /* Required for Firebase, AdMob(?) */
compile 'com.google.firebase:firebase-core:10.2.6' /* Firebase */
compile 'com.google.firebase:firebase-auth:10.2.6' /* Firebase - authentication */
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2' /* The new android ConstraintLayout */
compile 'com.google.firebase:firebase-messaging:10.2.6' /* Firebase - Cloud Messaging */
compile 'com.firebase:firebase-jobdispatcher:0.5.2' /* Firebase - Cloud Messaging Job Dispatcher */
}
apply plugin: 'com.google.gms.google-services'
Maybe the problem is here: My package name is com.dean.booktown
not com.dean.booktown-1
if that really is the problem, where do I find the mistake to fix it, and why did it happen in the first place?
Thank you very much,
Dean
com.dean.booktown-1
This is actually the folder where your APK is installed
Is the SDK and Google tools and libraries installed ? You should double check that since you swapped environment.
Edit;
From this question, is MultiDex enabled ?
MultiDex makes libraries with a lot of classes available to your app. To add it, see answer #2
I'm working on a small gradle based javafx project using netbeans ide (win7). Everything works fine until i included cloudant-sync and sqlite4java, now i get UnsatisfiedLinkError whenever i run the project. Please how do i resolve this.
java.lang.UnsatisfiedLinkError: no sqlite4java-win32-x64-1.0.392 in java.library.path
See gradle.build and console output below:
gradle.build
apply plugin: 'java'
sourceCompatibility = '1.8' [compileJava,
compileTestJava].options.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on
the // "mainClass" property. You may however define the property prior
executing // tasks by passing a "-PmainClass="
argument. // // Note however, that you may define your own "run" and
"debug" task if you // prefer. In this case NetBeans will not add
these tasks but you may rely on // your own implementation. if
(!hasProperty('mainClass')) {
ext.mainClass = 'falcon3.Main' }
repositories {
mavenCentral() }
dependencies {
compile 'com.jfoenix:jfoenix:1.1.0'
compile group: 'com.cloudant', name: 'cloudant-sync-datastore-javase', version:'2.0.0'
compile group: 'com.almworks.sqlite4java', name: 'sqlite4java', version: '1.0.392'
compile 'com.aquafx-project:aquafx:0.2'
testCompile group: 'junit', name: 'junit', version: '4.10' }
and
console output
Executing: gradle run Arguments: [-c,
C:\Users\???\Documents\NetBeansProjects\Falcon3\settings.gradle]
:compileJava UP-TO-DATE :processResources UP-TO-DATE :classes
UP-TO-DATE Feb 11, 2017 11:57:23 AM com.almworks.sqlite4java.Internal
log INFO: [sqlite] DB[1]: instantiated [null] Exception in Application
start method java.lang.reflect.InvocationTargetException at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at
com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start
method at
com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at
com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.lang.ExceptionInInitializerError at
com.cloudant.sync.internal.sqlite.SQLDatabaseQueue.(SQLDatabaseQueue.java:67)
at
com.cloudant.sync.internal.documentstore.DatabaseImpl.(DatabaseImpl.java:152)
at
com.cloudant.sync.documentstore.DocumentStore.(DocumentStore.java:90)
at
com.cloudant.sync.documentstore.DocumentStore.getInstance(DocumentStore.java:150)
at
com.cloudant.sync.documentstore.DocumentStore.getInstance(DocumentStore.java:120)
at falcon3.Main.start(Main.java:28) at
com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at
com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at
com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method) at
com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at
com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at
com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more Caused by: java.lang.IllegalStateException: Failed to open
database. at
com.cloudant.sync.internal.sqlite.sqlite4java.SQLiteWrapper.createNewConnection(SQLiteWrapper.java:92)
at
com.cloudant.sync.internal.sqlite.sqlite4java.SQLiteWrapper.getConnection(SQLiteWrapper.java:73)
at
com.cloudant.sync.internal.sqlite.sqlite4java.SQLiteWrapper.isOpen(SQLiteWrapper.java:121)
at
com.cloudant.sync.internal.sqlite.sqlite4java.SQLiteWrapper.beginTransaction(SQLiteWrapper.java:126)
at
com.cloudant.sync.internal.sqlite.SQLDatabaseFactory.isFtsAvailable(SQLDatabaseFactory.java:52)
at
com.cloudant.sync.internal.sqlite.SQLDatabaseFactory.(SQLDatabaseFactory.java:45)
... 15 more Caused by: com.almworks.sqlite4java.SQLiteException:
[-91] cannot load library: java.lang.UnsatisfiedLinkError: no
sqlite4java-win32-x64-1.0.392 in java.library.path at
com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97) at
com.almworks.sqlite4java.SQLiteConnection.open0(SQLiteConnection.java:1441)
at
com.almworks.sqlite4java.SQLiteConnection.open(SQLiteConnection.java:282)
at
com.cloudant.sync.internal.sqlite.sqlite4java.SQLiteWrapper.createNewConnection(SQLiteWrapper.java:88)
... 20 more Caused by: java.lang.UnsatisfiedLinkError: no
sqlite4java-win32-x64-1.0.392 in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
com.almworks.sqlite4java.Internal.tryLoadFromSystemPath(Internal.java:352)
at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:124)
at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95) ...
23 more Exception running application falcon3.Main :run FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':run'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_102\bin\java.exe'' finished with non-zero exit value 1
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.578 secs
Build failure (see the Notifications window for stacktrace): gradle
run
sqlite4java is not a pure Java package, but needs a binary build of the actual SQLite library. This has to be available to the JVM at runtime. The sqlite4java documentation says:
To start using sqlite4java, you only need to place sqlite4java.jar and platform-dependent binaries into a directory in the CLASSPATH. (Binaries should be in the same directory as the jar file.)
Try adding another dependency:
runtime group: 'com.almworks.sqlite4java', name: 'sqlite4java-win32-x64', version: '1.0.392'
This answer helped me: https://stackoverflow.com/a/39086207/3887715
Although the answer is based on DynamoDBLocal, you've already included the sqlite4java dependencies, so you should be able to get it working with a similar set-up.
You need to copy the library files to another directory:
task copyNativeDeps(type: Copy) {
from(configurations.compile + configurations.testCompile) {
include '*.dll'
include '*.dylib'
include '*.so'
}
into 'build/libs'
}
And then set the system property sqlite4java.library.path to the path to that directory. In my case, I needed it for a test, so I just added a initialiser block to my test class:
public class CreateDynamoDBTest {
{
System.setProperty("sqlite4java.library.path", "build/libs");
}
#Test
public void test() {
}
}
Who can help me fix error in my Android Project. I make sync with dropbox in my project, but when i try start app 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 №44 is mDbxAcctMgr = DbxAccountManager.getInstance(getApplicationContext(), appKey, appSecret);
I don't understand whats wrong?
Thx!
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 'build' and 'src' folder.
It looks like this is a general issue with native libraries and gradle. I found this SO answer helpful: Include .so library in apk in android studio
Part of my build.gradle file now looks like this, and my app starts 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)
}
You seem to miss the library for Dropbox (native part)
you can see that on 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 the library download or documentation where to get the missing library file
[UPDATE]: How To use native libraries with android studio
Put your *.so files inside a libs folder beside 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')
}
solution without copying data
Probably, most of us developers don't like to copy data from one location to another... So here's the solution without copying the .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 adjust the 2 occurences of my dropbox sync api folder to your own one ...