Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7669309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:33:54+00:00 2026-05-31T15:33:54+00:00

After getting no answer to my last question, I reformulated the thing to its

  • 0

After getting no answer to my last question, I reformulated the thing to its simplest form. 1 button, 1 clicklistener, 1 serializable object and 1 subroutine to output the serializable object. This code is based on about 6-8 examples I found here on stackoverflow. And yet as simple as it is it still generates this error: W/System.err(228): java.io.NotSerializableException: serobj.testActivity
So I challenge you, oh so wise code gurus: why does this code generate this error? And most importantly what do I do to fix it?
The entire code followed by log ouput:

package serobj;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import ser.obj.R;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;


public class testActivity extends Activity {
/** Called when the activity is first created. */
public class Tester implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
public String frog;
    public Tester(){
        frog="frog";
    }

}
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
       Testit();
    }
}); 
}
public void Testit(){
      Tester test = new Tester();

   FileOutputStream fos;
    try {
        fos =openFileOutput("test.fyl", Context.MODE_WORLD_READABLE);
        Log.d("file open","...");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        Log.d("ObjOutStr","...");
        oos.writeObject(test);  
        Log.d("tried wO","..."); // never gets here...
        oos.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        Log.d ("filenotfound", "filenotfound");
    }catch(IOException e){
        e.printStackTrace();
        Log.d("ioexception", "ioexception");
    }

}

}

03-17 04:40:02.691: D/file open(228): ...
03-17 04:40:02.701: D/ObjOutStr(228): ...
03-17 04:40:02.961: W/System.err(228): java.io.NotSerializableException: serobj.testActivity
03-17 04:40:02.971: W/System.err(228):  at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1547)
03-17 04:40:02.971: W/System.err(228):  at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1854)
03-17 04:40:02.971: W/System.err(228):  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1696)
03-17 04:40:02.971: W/System.err(228):  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1660)
03-17 04:40:02.971: W/System.err(228):  at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1153)
03-17 04:40:02.971: W/System.err(228):  at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:420)
03-17 04:40:02.981: W/System.err(228):  at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1251)
03-17 04:40:02.981: W/System.err(228):  at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1587)
03-17 04:40:02.981: W/System.err(228):  at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1854)
03-17 04:40:02.981: W/System.err(228):  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1696)
03-17 04:40:02.981: W/System.err(228):  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1660)
03-17 04:40:02.981: W/System.err(228):  at serobj.testActivity.Testit(testActivity.java:50)
03-17 04:40:03.015: W/System.err(228):  at serobj.testActivity$1.onClick(testActivity.java:37)
03-17 04:40:03.015: W/System.err(228):  at android.view.View.performClick(View.java:2364)
03-17 04:40:03.015: W/System.err(228):  at android.view.View.onTouchEvent(View.java:4179)
03-17 04:40:03.015: W/System.err(228):  at android.widget.TextView.onTouchEvent(TextView.java:6541)
03-17 04:40:03.015: W/System.err(228):  at android.view.View.dispatchTouchEvent(View.java:3709)
03-17 04:40:03.015: W/System.err(228):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-17 04:40:03.021: W/System.err(228):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-17 04:40:03.021: W/System.err(228):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-17 04:40:03.021: W/System.err(228):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-17 04:40:03.021: W/System.err(228):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-17 04:40:03.021: W/System.err(228):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
03-17 04:40:03.021: W/System.err(228):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
03-17 04:40:03.021: W/System.err(228):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
03-17 04:40:03.021: W/System.err(228):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
03-17 04:40:03.021: W/System.err(228):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
03-17 04:40:03.021: W/System.err(228):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-17 04:40:03.031: W/System.err(228):  at android.os.Looper.loop(Looper.java:123)
03-17 04:40:03.031: W/System.err(228):  at android.app.ActivityThread.main(ActivityThread.java:4363)
03-17 04:40:03.031: W/System.err(228):  at java.lang.reflect.Method.invokeNative(Native Method)
03-17 04:40:03.031: W/System.err(228):  at java.lang.reflect.Method.invoke(Method.java:521)
03-17 04:40:03.031: W/System.err(228):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-17 04:40:03.031: W/System.err(228):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-17 04:40:03.031: W/System.err(228):  at dalvik.system.NativeStart.main(Native Method)
03-17 04:40:03.031: D/ioexception(228): ioexception
03-17 04:51:21.861: D/dalvikvm(56): threadid=15: bogus mon 1+0>0; adjusting
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:33:55+00:00Added an answer on May 31, 2026 at 3:33 pm

    Be cause your inner class is not static, so to exist as a serialized thing, it will need the instance of the outter class and an activity is not serializabled. Make Tester a separate class or make it a static inner class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After getting fine answer to my previous question , I came across another problem.
After getting the right answer from this question , I am having another problem
After getting the answer from this question , I came across another problem -
After getting a helpful answer here , I have run into yet another problem:
I have designed one sign-up form,in this form after getting all necessary values I
After I finished running my function, I kept on getting 0s as my answer:
After getting an answer from this thread, it would save me alot of retyping
Hey guys. This is a follow-on from this question : After getting the right
Example #1 bschaeffer's answer to this question - in his last example: $this->load->model('table'); $data
getting really confused here now after googling for the last 40 mins. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.