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

yorkw
  • 40,926
  • 10
  • 117
  • 130
Nishit
  • 63
  • 1
  • 7
  • Next time it'd be great if you posted _full_ logs and code. –  Jul 07 '12 at 08:47
  • @user942821: Thanks for the comment, I will make sure from next time onwards i will put the logs and code properly. – Nishit Aug 07 '12 at 08:10

1 Answers1

1

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

See this

Community
  • 1
  • 1
nullpotent
  • 9,162
  • 1
  • 31
  • 42
  • 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 – Nishit Aug 07 '12 at 08:00