The errors:
Process: com.example.syafiq.opencvoi, PID: 7760
java.lang.UnsatisfiedLinkError: Couldn't load native_sample from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.example.syafiq.opencvoi-13.apk,libraryPath=/data/app-lib/com.example.syafiq.opencvoi-13]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.example.syafiq.opencvoi.Sample3Native$1.onManagerConnected(Sample3Native.java:79)
at org.opencv.android.AsyncServiceHelper$3.onServiceConnected(AsyncServiceHelper.java:319)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1114)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1131)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
The sample3Native.java line 79 were:
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
// Load native library after(!) OpenCV initialization
System.loadLibrary("native_sample");
And the AsyncServiceHelper.Java line 319 were
mUserAppCallback.onManagerConnected(status);
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include ../../sdk/native/jni/OpenCV.mk
LOCAL_MODULE := native_sample
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
And application.mk
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi armeabi-v7a
LOCAL_ARM_NEON := true
There's no errors in the codes. I've tried several solution but yet the result are still the same, The codes was obtained from open source website. I'm not good enough with android studio, and I'm still learning. I hope you guys can help me to solve this error. I really appreciate your help and consideration to help me and solve my error. I appreciate your time :)
From my perspective something wrong with versions of your "native_sample" library. As it's written in documentation
Thrown if the Java Virtual Machine cannot find an appropriate
native-language definition of a method declared native.
It's possible that there are both versions in your classpath, and jvm loads wrong version. So it finds library but during class-loading process find inconsistency, probably required method was added in later lib version.
I suggest trying this:
System.load(String path) //with an absolute path to needed lib
Also see: Difference between System.load() and System.loadLibrary in Java
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.syafiq.opencvoi"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
// jniLibs.srcDirs = ['libs']
main{
jniLibs{
srcDir 'libs'
}
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':libraries:opencv')
}
Related
Android app crashes in phone when build using Release Type but works fine when build using debug build type or if debugging is enabled in release mode.
Logcat error are showing verify error due to one of the abstract class
There are no proguard files in the application. i have tried by adding
'useProguard false' in build.gradle but it won't help
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28
defaultConfig {
applicationId "com.newgen.mcap.srei"
minSdkVersion 21
targetSdkVersion 28
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
checkReleaseBuilds false
disable "ResourceType"
}
}
dependencies {
compile 'com.android.support:support-v4:23.4.0'
compile files('libs/com.antlersoft.android.db_0.1.6.jar')
compile files('libs/commons-lang3-3.1.jar')
compile files('libs/dmsapi.jar')
compile files('libs/ImgAndro.jar')
compile files('libs/NGSecurity.jar')
}
Logcat error in here:
--------- beginning of crash
2019-01-14 16:34:28.599 16678-16696/com.newgen.mcap.srei E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.newgen.mcap.srei, PID: 16678
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.VerifyError: Rejecting class com.newgen.mcap.client.custom.CustomHelper_1_1 that attempts to sub-type erroneous class com.newgen.mcap.client.util.DefaultCustomHelper (declaration of 'com.newgen.mcap.client.custom.CustomHelper_1_1' appears in /data/app/com.newgen.mcap.srei-1/base.apk)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName(NGCaptureSingleton.java:109)
at com.newgen.mcap.client.util.NGCaptureSingleton.loadXMLConfiguration(NGCaptureSingleton.java:591)
at com.newgen.mcap.client.util.NGCaptureSingleton.initConfiguration(NGCaptureSingleton.java:414)
at com.newgen.mcap.client.util.NGCaptureSingleton.setAssets(NGCaptureSingleton.java:96)
at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:145)
at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:120)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.VerifyError: Verifier rejected class com.newgen.mcap.client.util.DefaultCustomHelper: java.lang.String[] com.newgen.mcap.client.util.DefaultCustomHelper.selectMasterData(java.lang.String, java.lang.String, java.util.LinkedHashMap, boolean) failed to verify: java.lang.String[] com.newgen.mcap.client.util.DefaultCustomHelper.selectMasterData(java.lang.String, java.lang.String, java.util.LinkedHashMap, boolean): [0xCA] returning undefined register (declaration of 'com.newgen.mcap.client.util.DefaultCustomHelper' appears in /data/app/com.newgen.mcap.srei-1/base.apk)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName(NGCaptureSingleton.java:109)
at com.newgen.mcap.client.util.NGCaptureSingleton.loadXMLConfiguration(NGCaptureSingleton.java:591)
at com.newgen.mcap.client.util.NGCaptureSingleton.initConfiguration(NGCaptureSingleton.java:414)
at com.newgen.mcap.client.util.NGCaptureSingleton.setAssets(NGCaptureSingleton.java:96)
at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:145)
at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:120)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
My question is not a duplicate of Link
as crash is due to build type and not due to android api level. And i have tried the accepted answer by deleting the build and release folder before building apk.
It is not related to debug/release build. You should handle exception in
com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName
(NGCaptureSingleton.java:109)
Steps 1: Open Android Studio Setting and go to Build, Execution, Deployment -> Gradle
Copy Gradle Service Directory Path
In my case that is C:/Users/bhanu.sharma/.gradle
Step 2: Open File Explorer and Paste the Gradle service directory Path
Add the file gradle.properties in here if it is not present
Step 3: Open Android Studio and change project type to Android, You will see
gradle.properties file here
Step 4: Add the line android.enableD8=false in gradle.properties file.
Step 5: Clean and Build the signed apk.
I'm continuously getting this error report in my Google Play developer console. It look like MultiDex error.
java.lang.RuntimeException:
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4514)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method:0)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newApplication(Instrumentation.java:975)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
I already added this to gradle.build:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
#Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
try {
MultiDex.install(this);
}catch (RuntimeException e){
e.printStackTrace();
}catch (Exception e){
e.printStackTrace();
}
}
I'm still getting this error in android 4.4,5.0,5.1, 6.0. Please help !!
There are multiple variants of the java.lang.ClassNotFoundException in Android, most of them are caused by a wrong Proguard configuration, IDE not closing correctly the previous launched instance of the device during build time etc.
Follow Unexpected crash in BaseDexClassLoader for more details.
It might be because of conflict in dependencies (same class may exists in two libraries).
So search for BaseDexClassLoader class in your dependencies.
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 am getting this error:
12-17 03:59:18.767 7516-8610/io.ustube.ustube E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: io.ustube.ustube, PID: 7516
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.NoClassDefFoundError: com.google.gson.internal.$Gson$Preconditions
at com.google.gson.reflect.TypeToken.<init>(TypeToken.java:72)
at com.google.gson.reflect.TypeToken.get(TypeToken.java:296)
at com.google.gson.Gson.toJson(Gson.java:644)
at com.google.gson.Gson.toJson(Gson.java:631)
at com.google.gson.Gson.toJson(Gson.java:586)
at com.google.gson.Gson.toJson(Gson.java:566)
at io.ustube.ustube.LoginActivity$VerifyTask.doInBackground(LoginActivity.java:338)
at io.ustube.ustube.LoginActivity$VerifyTask.doInBackground(LoginActivity.java:310)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
but I know that the mentioned class is a dependency. I've looked through the jar file myself. Also, I only get this error below 5.0.
My gradle file includes compile 'com.google.code.gson:gson:2.5'
NoClassDefFoundError in Java comes when Java Virtual Machine is not
able to find a particular class at runtime which was available during
compile time. For example, if we have a method call from a class or
accessing any static member of a Class and that class is not available
during run-time then JVM will throw NoClassDefFoundError.
You can try with
compile 'com.google.code.gson:gson:2.3'
Then , Modify your app Gradle build file configuration to include the support library and enable multidex output .
android {
compileSdkVersion 21 // Set Yours
buildToolsVersion "21.1.0" // Set Yours
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21 // Set Yours
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
More details
DexIndexOverflowException Only When Running Tests
This thing happens a lot. You should be able to fix by doing the following,
multiDexEnabled = false
in your build.gradle file.
If you already have multiDexEnabled = true then change it to false or add this new line.
Use compile 'com.android.support:multidex:1.0.0' then extends MultiDexApplication in your application class.
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 ...