1

Exception stack trace:

java.lang.RuntimeException: An error occured while executing doInBackground() E/AndroidRuntime( 695): at android.os.AsyncTask$3.done(AsyncTask.java:200) E/AndroidRuntime( 695): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) E/AndroidRuntime( 695): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) E/AndroidRuntime( 695): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) E/AndroidRuntime( 695): at java.util.concurrent.FutureTask.run(FutureTask.java:137) E/AndroidRuntime( 695): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) E/AndroidRuntime( 695): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) E/AndroidRuntime( 695): at java.lang.Thread.run(Thread.java:1096) E/AndroidRuntime( 695): Caused by: java.lang.NoClassDefFoundError: com.google.gson.Gson E/AndroidRuntime( 695): at com.amphisoft.mebox.LoginActivity$LoginTask.doInBackground(LoginActivity.java:167) E/AndroidRuntime( 695): at com.amphisoft.mebox.LoginActivity$LoginTask.doInBackground(LoginActivity.java:1) E/AndroidRuntime( 695): at android.os.AsyncTask$2.call(AsyncTask.java:185) E/AndroidRuntime( 695): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) E/AndroidRuntime( 695): ... 4 more

This is my code:

protected User doInBackground(User... user) {
        HttpClient httpClient = new DefaultHttpClient();
        try {
            HashMap<String, String> parameters = new HashMap<String, String>();
            parameters.put("username", user[0].username);
            parameters.put("password", user[0].password);
            String response = HTTPUtil.post("/user/login.json", parameters,
                    null);
            System.out.println("Response:" + response);
            Gson gson = new Gson();
            User userObj = gson.fromJson(response, User.class);
            Store.getInstance().user = userObj;

        }

I tried adding gson-2.1jar many times in the library.. But getting the same error as class definition not found.. Please help me. Thanks in advance..

2
  • Next time it'd be great if you posted full logs and code. Commented Jul 7, 2012 at 8:47
  • @user942821: Thanks for the comment, I will make sure from next time onwards i will put the logs and code properly. Commented Aug 7, 2012 at 8:10

1 Answer 1

1

Create a libs folder and put gson in there, then add the folder to the library path.

See this

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for replying late. I did that, it was working fine. Then i found that I was using network through proxy. So I had to set proxy in my emulator. Not its working fine. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.