1
AndroidアプリからAzureにデータを送信しようとしています。私はAzureが提供するモバイルサービスの設定例を使用しています。コードにエラーはありませんが、ボタン上のアクティビティをロードしようとすると、アプリケーションがクラッシュします。私がロードしようとしているアクティビティには、onCreateメソッドのAzureインタラクションコードがあります。Androidの致命的な例外とAzureのやりとり
UPDATE
これは他のAndroidデバイス上で動作しますが、私がしようとするとサムスンギャラクシーS3ミニは、Androidバージョンを走っ上でそれを実行したときに、それがクラッシュ4.1.2。
Register.java
package com.example.martin.ivebeenthere;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Toast;
import com.microsoft.windowsazure.mobileservices.MobileServiceClient;
import com.microsoft.windowsazure.mobileservices.http.ServiceFilterResponse;
import com.microsoft.windowsazure.mobileservices.table.TableOperationCallback;
import java.net.MalformedURLException;
public class Register extends AppCompatActivity {
private MobileServiceClient mClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
try {
mClient = new MobileServiceClient(
"AZURE ACCOUNT",
"AZURE KEY",
this
);
} catch (MalformedURLException e) {
e.printStackTrace();
}
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
} else {
// Insert failed
}
}
});
}
public void onClickbtnRegister(View view)
{
startActivity(new Intent(Register.this, Login.class));
Toast.makeText(getApplicationContext(), "Successfully Registered",
Toast.LENGTH_LONG).show();
}
}
Item.java
package com.example.martin.ivebeenthere;
/**
* Created by Martin on 31/03/2016.
*/
public class Item {
public String Id;
public String Text;
}
Logcat
04-06 10:28:31.570 15331-15331/com.example.martin.ivebeenthere E/AndroidRuntime: FATAL EXCEPTION: main 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.example.martin.ivebeenthere.Register.onCreate(Register.java:30)
at android.app.Activity.performCreate(Activity.java:5047)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
at android.app.ActivityThread.access$700(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
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:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
:以下
はbuild.gradleで依存関係のリストを見て、あなたが持っていることを確認。 –