1

我是 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);

此代码出现错误。

4

2 回答 2

2

使用您的应用程序密钥将“db-XXXXXXXXXXXXXX”行更改为“db-jd7ld246chdlkej”。

  <activity
  android:name="com.dropbox.client2.android.AuthActivity"
  android:launchMode="singleTask"
  android:configChanges="orientation|keyboard">
  <intent-filter>
    <!-- Change this to be db- followed by your app key -->
    <data android:scheme="db-jd7ld246chdlkej" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.BROWSABLE"/>
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>
于 2015-02-13T09:13:04.217 回答
0

该异常(无法加载 DropboxSync:findLibrary 返回 null)意味着在运行时无法找到 libDropboxSync.so。我不熟悉 gradle 构建过程,但我建议看一下 native-libs.jar 的内容。.so 可能丢失,或者它不包含正确的平台(armeabi 是最常见的),或者 jar 文件的结构可能不正确(它应该包含每个平台的子目录,带有 .每个子目录中的so文件)。

于 2013-11-12T17:35:29.353 回答