我正在按照这个 Dropbox 教程来启动和设置我的“Hello Dropbox 同步应用程序”。
尽管我将按照教程中给出的步骤进行操作,但我会遇到错误。
权限、应用程序密钥、应用程序秘密等都在他们的位置上,但仍然没有得到我要去的地方。请帮助我摆脱困境。提前致谢
这是我的 Manifest.xml :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bguru.mydropboxdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.bguru.mydropboxdemo.MyDropboxDemoActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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-MY_APP_KEY" />
<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" />
</application>
爪哇代码:
public class MyDropboxDemoActivity extends Activity implements OnClickListener
{
Button btnLinkToDropbox;
DbxAccountManager dropBoxAcMngr;
static final int REQUEST_LINK_TO_DROPBOX = 444;
static final String APP_KEY = "MY_APP_KEY";
static final String APP_SECRET = "MY_APP_SECRET";
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_dropbox_demo);
dropBoxAcMngr = DbxAccountManager.getInstance(this, APP_KEY , APP_SECRET);
btnLinkToDropbox = (Button) findViewById(R.id.btnLinkDropboxAC);
btnLinkToDropbox.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
dropBoxAcMngr.startLink(getParent(), REQUEST_LINK_TO_DROPBOX);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == REQUEST_LINK_TO_DROPBOX)
{
if(resultCode == Activity.RESULT_OK)
{
btnLinkToDropbox.setText("Successfully Linked To Your Dropbox Account");
btnLinkToDropbox.setEnabled(false);
Toast.makeText(this, "Account Linked", Toast.LENGTH_LONG).show();
}
else
{
btnLinkToDropbox.setText("Failed to Link Your Dropbox Account\nTry Again?");
Toast.makeText(getApplicationContext(), "Account Linking failed", Toast.LENGTH_LONG).show();
}
}
super.onActivityResult(requestCode, resultCode, data);
}
}
logcat 显示:
04-17 11:08:52.740: E/AndroidRuntime(4492): FATAL EXCEPTION: main
04-17 11:08:52.740: E/AndroidRuntime(4492): java.lang.ExceptionInInitializerError
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.dropbox.sync.android.CoreAccountManager.initNativeLib(CoreAccountManager.java:109)
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.dropbox.sync.android.CoreAccountManager.<init>(CoreAccountManager.java:89)
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.dropbox.sync.android.DbxAccountManager.getInstance(DbxAccountManager.java:112)
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.dropbox.sync.android.DbxAccountManager.getInstance(DbxAccountManager.java:99)
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.bguru.mydropboxdemo.MyDropboxDemoActivity.onCreate(MyDropboxDemoActivity.java:27)
04-17 11:08:52.740: E/AndroidRuntime(4492): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-17 11:08:52.740: E/AndroidRuntime(4492): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1662)
04-17 11:08:52.740: E/AndroidRuntime(4492): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1726)
04-17 11:08:52.740: E/AndroidRuntime(4492): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-17 11:08:52.740: E/AndroidRuntime(4492): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:949)
04-17 11:08:52.740: E/AndroidRuntime(4492): at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 11:08:52.740: E/AndroidRuntime(4492): at android.os.Looper.loop(Looper.java:130)
04-17 11:08:52.740: E/AndroidRuntime(4492): at android.app.ActivityThread.main(ActivityThread.java:3770)
04-17 11:08:52.740: E/AndroidRuntime(4492): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 11:08:52.740: E/AndroidRuntime(4492): at java.lang.reflect.Method.invoke(Method.java:507)
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638)
04-17 11:08:52.740: E/AndroidRuntime(4492): at dalvik.system.NativeStart.main(Native Method)
04-17 11:08:52.740: E/AndroidRuntime(4492): Caused by: java.lang.ExceptionInInitializerError
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.dropbox.sync.android.NativeLib.<init>(NativeLib.java:33)
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.dropbox.sync.android.NativeLib.<clinit>(NativeLib.java:11)
04-17 11:08:52.740: E/AndroidRuntime(4492): ... 18 more
04-17 11:08:52.740: E/AndroidRuntime(4492): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load DropboxSync: findLibrary returned null
04-17 11:08:52.740: E/AndroidRuntime(4492): at java.lang.Runtime.loadLibrary(Runtime.java:429)
04-17 11:08:52.740: E/AndroidRuntime(4492): at java.lang.System.loadLibrary(System.java:554)
04-17 11:08:52.740: E/AndroidRuntime(4492): at com.dropbox.sync.android.NativeHttp.<clinit>(NativeHttp.java:364)
04-17 11:08:52.740: E/AndroidRuntime(4492): ... 20 more