[android]NoClassDefFoundError: com.microsoft.windowsazure.mobileservices.MobileServiceAuthenticationProvider

标签: Android windows
发布时间: 2014/2/4 4:21:03
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

Iam 使得 android 的应用程序将到一个活动目录对用户进行身份验证。目前,我已在http://www.windowsazure.com/en-us/documentation/articles/mobile-services-android-get-started-users/跟着教程。

我只需要在此时对用户进行身份验证。所以我做了以下内容:-

import com.microsoft.windowsazure.mobileservices.MobileServiceApplication;
import com.microsoft.windowsazure.mobileservices.MobileServiceAuthenticationProvider;
import com.microsoft.windowsazure.mobileservices.MobileServiceClient;
import com.microsoft.windowsazure.mobileservices.MobileServiceUser;
import com.microsoft.windowsazure.mobileservices.ServiceFilterResponse;
import com.microsoft.windowsazure.mobileservices.UserAuthenticationCallback;

    public static MobileServiceClient mobileServiceClient;
    public MobileServiceUser _user;
    MobileServiceClient mCLient;
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        web = (WebView)findViewById(R.id.webSignin);


        web.getSettings().setJavaScriptEnabled(true);
        web.loadUrl("https://login.microsoftonline.com/login.srf?wa=wsignin1%2E0&rpsnv=2&ct=1390811289&rver=6%2E1%2E6206%2E0&wp=MBI&wreply=https%3A%2F%2Fwww7679%2Esharepoint%2Ecom%2F%5Flayouts%2F15%2Flanding%2Easpx%3FSource%3Dhttps%253A%252F%252Fzevenseascom%252D11%252Esharepoint%252Eemea%252Emicrosoftonline%252Ecom%252F%255Fforms%252Fdefault%252Easpx&lc=16393&id=500046&guests=1");


        authenticate();



    }

    private void authenticate()
    {
        // TODO Auto-generated method stub
        mCLient.login(MobileServiceAuthenticationProvider.Google, new UserAuthenticationCallback()
        {

            @Override
            public void onCompleted(MobileServiceUser user, Exception exception,
                    ServiceFilterResponse response) 
            {
                // TODO Auto-generated method stub
                if(exception == null)
                {
                    createAndShowDialog(String.format("You are now logged in - %1$2s", user.getUserId()),"Success");
                    Intent myIntent = new Intent(MainActivity.this, Directory.class);
                    startActivity(myIntent);

                }
                else
                {
                     createAndShowDialog("You must log in. Login Required", "Error");
                }
            }
        });
    }

但我得到了以下错误:-

java.lang.NoClassDefFoundError: com.microsoft.windowsazure.mobileservices.MobileServiceAuthenticationProvider
01-28 10:34:04.732: E/AndroidRuntime(2150):     at com.example.activedirectory.MainActivity.authenticate(MainActivity.java:68)

任何帮助被赞赏

解决方法 1:

请为 init MobileServiceClient mCLient; 你只是声明,未初始化。也许是的

mClient = new MobileServiceClient(...); 

与错误:

    -01-28 11:56:50.974: E/AndroidRuntime(6793): 
java.lang.NoClassDefFoundError: com.google.gson.GsonBuilder 01-28 11:56:50.974: E/AndroidRuntime(6793): at com.microsoft.windowsazure.mobileservices.MobileServiceClient.createMobileServic‌​eGsonBuilder(MobileServiceClient.java:136) 01-28 11:56:50.974: 
E/AndroidRuntime(6793): at com.microsoft.windowsazure.mobileservices.MobileServiceClient.<init>(MobileServi‌​ceClient.java:187)

只需添加库: GSON

官方微信
官方QQ群
31647020