Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android致命异常与Azure交互_Java_Android_Azure_Azure Mobile Services_Fatal Error - Fatal编程技术网

Java Android致命异常与Azure交互

Java Android致命异常与Azure交互,java,android,azure,azure-mobile-services,fatal-error,Java,Android,Azure,Azure Mobile Services,Fatal Error,我正在尝试从我的Android应用程序向Azure发送一些数据。我在设置移动服务时使用Azure提供的示例。我的代码中没有错误,但当我尝试在按钮上加载活动时,单击应用程序会崩溃。我试图加载的活动在onCreate方法上有Azure交互代码 更新 这可以在其他android设备上运行,但当我尝试在三星Galaxy S3 Mini运行android版本4.1.2时,它崩溃了 Register.java package com.example.martin.ivebeenthere; import

我正在尝试从我的Android应用程序向Azure发送一些数据。我在设置移动服务时使用Azure提供的示例。我的代码中没有错误,但当我尝试在按钮上加载活动时,单击应用程序会崩溃。我试图加载的活动在onCreate方法上有Azure交互代码

更新

这可以在其他android设备上运行,但当我尝试在三星Galaxy S3 Mini运行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();
    }

}
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)
04-06 10:28:31.570 15331-15331/com.example.martin.ivebeenthere E/AndroidRuntime:FATAL EXCEPTION:main java.lang.NoClassDefFoundError:com.google.gson.GsonBuilder
位于com.microsoft.windowsazure.mobileseservices.mobileseserviceclient.createmobileseservicegsonbuilder(mobileseserviceclient.java:192)
位于com.microsoft.windowsazure.mobileservices.MobileServiceClient。(MobileServiceClient.java:179)
位于com.microsoft.windowsazure.mobileservices.MobileServiceClient。(MobileServiceClient.java:158)
在com.example.martin.ivebeenthere.Register.onCreate(Register.java:30)上
位于android.app.Activity.performCreate(Activity.java:5047)
位于android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)上
位于android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
在android.app.ActivityThread.access$700(ActivityThread.java:134)
在android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
位于android.os.Handler.dispatchMessage(Handler.java:99)
位于android.os.Looper.loop(Looper.java:137)
位于android.app.ActivityThread.main(ActivityThread.java:4867)
位于java.lang.reflect.Method.Invokenactive(本机方法)
位于java.lang.reflect.Method.invoke(Method.java:511)
在com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)上
位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
在dalvik.system.NativeStart.main(本机方法)

您的依赖项中是否有com.google.code.gson

查看build.gradle中的依赖项列表,确保您具有以下内容:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.google.guava:guava:18.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.microsoft.azure:azure-mobile-android:3.1.0'
    compile (group: 'com.microsoft.azure', name: 'azure-notifications-handler', version: '1.0.1', ext: 'jar')
}

我有所有的依赖项。