【发布时间】:2015-12-13 15:47:24
【问题描述】:
我正在尝试将 Azure 连接到 Android Studios。我按照 Azure 上的教程创建了一个移动服务。然后它给了我一些代码来添加到我的应用程序中,以便它们连接起来。但是,代码抛出了一个我无法弄清楚的异常。我从头到脚搜索了互联网,但找不到答案。我认为这与依赖项或库的导入方式有关(通过将 jar 文件粘贴到 libs 文件夹并添加依赖项)。
引发异常的代码(Azure提供):
try {
mClient = new MobileServiceClient(
"https://atm.azure-mobile.net/",
"JWjetFMUVaAXzHmqDVqhkkRhTGGjeW70",
this
);
Item item = new Item();
item.Text = "Awesome item";
mClient.getTable(Item.class).insert(item, new TableOperationCallback<Item>() {
public void onCompleted(Item entity, Exception exception, ServiceFilterResponse response) {
if (exception == null) {
// Insert succeeded
Toast.makeText(context, "WOOHOO", Toast.LENGTH_LONG).show();
} else {
// Insert failed
Toast.makeText(context, "FAILED", Toast.LENGTH_LONG).show();
}
}
});
}
catch(MalformedURLException d) {
}
例外:
java.lang.NoClassDefFoundError: com.google.gson.GsonBuilder
at com.microsoft.windowsazure.mobileservices.MobileServiceClient.createMobileServiceGsonBuilder(MobileServiceClient.java:192)
at com.microsoft.windowsazure.mobileservices.MobileServiceClient.<init>(MobileServiceClient.java:179)
at com.microsoft.windowsazure.mobileservices.MobileServiceClient.<init>(MobileServiceClient.java:158)
at com.atmlocator.hooper.kenneth.atmlocator.HomeActivity.onCreate(HomeActivity.java:218)
at android.app.Activity.performCreate(Activity.java:5047)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2051)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2112)
at android.app.ActivityThread.access$700(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1223)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4917)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:997)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
at dalvik.system.NativeStart.main(Native Method)
【问题讨论】:
标签: java android azure android-studio azure-mobile-services