NoClassDefFoundError: com.microsoft.windowsazure.mobileservices.MobileServiceAuthenticationProvider

StackOverflow https://stackoverflow.com/questions/21397424

Question

Iam making an android app which will authenticate a user into an active directory. Currently, I have followed a tutorial on http://www.windowsazure.com/en-us/documentation/articles/mobile-services-android-get-started-users/.

I only need to authenticate a user at this point. So I have done the following:-

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");
                }
            }
        });
    }

But i get the following 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)

Any help is appreciated

Was it helpful?

Solution

Please init for MobileServiceClient mCLient; You just declare, not init. May be it is

mClient = new MobileServiceClient(...); 

And with error:

    -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)

just add library: GSON

OTHER TIPS

Have you tried this solution.
Project Properties>Java Build Path>Order and Import tab and check the libraries you are using.

It seems that ADT update 22, you have to do this manually: Libraries do not get added to APK anymore after upgrade to ADT 22.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top