我是 Android 开发的新手,我正在使用 Eclipse 开发一个 Android 应用程序。我想实现在 Dropbox 上同步数据库的功能。现在得到,
11-12 13:35:30.985: E/AndroidRuntime(4555): FATAL EXCEPTION: main
11-12 13:35:30.985: E/AndroidRuntime(4555): java.lang.ExceptionInInitializerError
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.dropbox.sync.android.CoreAccountManager.initNativeLib(CoreAccountManager.java:155)
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.dropbox.sync.android.CoreAccountManager.<init>(CoreAccountManager.java:126)
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.dropbox.sync.android.DbxAccountManager.getInstance(DbxAccountManager.java:149)
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.dropbox.sync.android.DbxAccountManager.getInstance(DbxAccountManager.java:115)
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.example.smereceipt.NewReceiptScreen2.onCreate(NewReceiptScreen2.java:87)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.app.Activity.performCreate(Activity.java:5206)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.os.Looper.loop(Looper.java:137)
11-12 13:35:30.985: E/AndroidRuntime(4555): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-12 13:35:30.985: E/AndroidRuntime(4555): at java.lang.reflect.Method.invokeNative(Native Method)
11-12 13:35:30.985: E/AndroidRuntime(4555): at java.lang.reflect.Method.invoke(Method.java:511)
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-12 13:35:30.985: E/AndroidRuntime(4555): at dalvik.system.NativeStart.main(Native Method)
11-12 13:35:30.985: E/AndroidRuntime(4555): Caused by: java.lang.ExceptionInInitializerError
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.dropbox.sync.android.NativeLib.<init>(NativeLib.java:33)
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.dropbox.sync.android.NativeLib.<clinit>(NativeLib.java:11)
11-12 13:35:30.985: E/AndroidRuntime(4555): ... 19 more
11-12 13:35:30.985: E/AndroidRuntime(4555): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load DropboxSync: findLibrary returned null
11-12 13:35:30.985: E/AndroidRuntime(4555): at java.lang.Runtime.loadLibrary(Runtime.java:365)
11-12 13:35:30.985: E/AndroidRuntime(4555): at java.lang.System.loadLibrary(System.java:535)
11-12 13:35:30.985: E/AndroidRuntime(4555): at com.dropbox.sync.android.NativeHttp.<clinit>(NativeHttp.java:446)
11-12 13:35:30.985: E/AndroidRuntime(4555): ... 21 more
错误。
我的代码是这样的,
清单.xml
<!-- For Dropbox -->
<activity android:name="com.dropbox.sync.android.DbxAuthActivity" />
<activity
android:name="com.dropbox.client2.android.AuthActivity"
android:launchMode="singleTask" >
<intent-filter>
<data android:scheme="db-XXXXXXXXXXXXXX" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name="com.dropbox.sync.android.DbxSyncService"
android:enabled="true"
android:exported="false"
android:label="Dropbox Sync" />
我还添加了build.gradle 之类的,
dependencies {
compile files('libs/dropbox-sync-sdk-android.jar')
compile files("$buildDir/native-libs/native-libs.jar")
compile 'com.android.support:support-v4:18.0.0'
}
task nativeLibsToJar(type: Zip) {
destinationDir file("$buildDir/native-libs")
baseName 'native-libs'
extension 'jar'
from fileTree(dir: 'libs', include: '**/*.so')
into 'lib/'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn nativeLibsToJar
}
当我执行
mDbxAcctMgr = DbxAccountManager.getInstance(getApplicationContext(), appKey, appSecret);
此代码出现错误。