NavigationView NotSerializableException while pushing fragment - android

I am getting NotSerializableException when pushing one of my fragments in my app. I am using navigation view in my activity for side menu.
Caused by: java.io.NotSerializableException: android.support.design.widget.NavigationView
I have a ProfileFragment in my MainActivity. I am re using my EntriesList fragment inside ProfileFragment. On clicking an item in EntriesList, the EntryDetailsFragment is being pushed to main container. This is crashing the app with above message. I have included complete stack trace below.
FATAL EXCEPTION: main
Process: com.ajith.trivado, PID: 5597
java.lang.RuntimeException: Parcelable encountered IOException writing
serializable object (name = com.ajith.trivado.activities.MainActivity)
at android.os.Parcel.writeSerializable(Parcel.java:1316)
at android.os.Parcel.writeValue(Parcel.java:1264)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
at android.os.Bundle.writeToParcel(Bundle.java:1692)
at android.os.Parcel.writeBundle(Parcel.java:636)
at android.app.FragmentState.writeToParcel(Fragment.java:132)
at android.os.Parcel.writeTypedArray(Parcel.java:1133)
at
android.app.FragmentManagerState.writeToParcel(FragmentManager.java:373)
at android.os.Parcel.writeParcelable(Parcel.java:1285)
at android.os.Parcel.writeValue(Parcel.java:1204)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
at android.os.Bundle.writeToParcel(Bundle.java:1692)
at android.os.Parcel.writeBundle(Parcel.java:636)
at
android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2506)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3165)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.io.NotSerializableException:
android.support.design.widget.NavigationView
at
java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1364)
at
java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
at
java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:979)
at
java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
at
java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1074)
at
java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1404)
at
java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1671)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1517)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
at android.os.Parcel.writeSerializable(Parcel.java:1311)
at android.os.Parcel.writeValue(Parcel.java:1264) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618) 
at android.os.Bundle.writeToParcel(Bundle.java:1692) 
at android.os.Parcel.writeBundle(Parcel.java:636) 
at android.app.FragmentState.writeToParcel(Fragment.java:132) 
at android.os.Parcel.writeTypedArray(Parcel.java:1133) 
at
android.app.FragmentManagerState.writeToParcel(FragmentManager.java:373) 
at android.os.Parcel.writeParcelable(Parcel.java:1285) 
at android.os.Parcel.writeValue(Parcel.java:1204) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618) 
at android.os.Bundle.writeToParcel(Bundle.java:1692) 
at android.os.Parcel.writeBundle(Parcel.java:636) 
at
android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2506) 
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3165) 
at android.os.Handler.handleCallback(Handler.java:733) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5086) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method)

I should see the code but I think you are sending some extra data to your fragment. The class of your object that is being sent should implement Serializable.

Related

E/AndroidRuntime: FATAL EXCEPTION: main PID: 5112 [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 5 years ago.
Hy
I am new to Android / Java is I am facing a BMO problem
I code it but it does not work
an idea ??
thank you
<string name="onCreate_Go">onCreate Go</string>
<TextView
android:id="#+id/scrollTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
import android.widget.TextView;
private final TextView txt = (TextView) this.findViewById(R.id.scrollTxt);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt.setText(R.string.onCreate_Go);
}
5112-5112/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gmail.test1, PID: 5112
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.gmail.test1/com.gmail.test1.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.support.v7.app.AppCompatDelegateImplBase.(AppCompatDelegateImplBase.java:117)
at android.support.v7.app.AppCompatDelegateImplV9.(AppCompatDelegateImplV9.java:149)
at android.support.v7.app.AppCompatDelegateImplV11.(AppCompatDelegateImplV11.java:29)
at android.support.v7.app.AppCompatDelegateImplV14.(AppCompatDelegateImplV14.java:54)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
at android.support.v7.app.AppCompatActivity.findViewById(AppCompatActivity.java:190)
at com.gmail.test1.MainActivity.(MainActivity.java:13)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
02-16 16:41:21.634 5112-5112/? I/Process: Sending signal. PID: 5112 SIG: 9
Please add your Activity in your AndroidManifest.xml. like below code:
<activity android:name=".activities.MainActivity"/>
Also put the findViewById() after setContentView() so it can actually return something other than null.
You can't initialize the textView before call "setContentView" method. I recommend you create a "init" method where initialize all layout's elements and call it after "setContentView"

com.facebook.accountkit.ui.AccountKitActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class TextView

Working on facebook account kit for android.
Got this issue on launch of login activity.
what is solution, dont able to find out,
Here is whole exception..
i all ready post this bug in facebook github page, but not got answer till now.
This code is working on some latest version of android, Andorid 4.0 this is not working.
Process: abc.co.com, PID: 14438
java.lang.RuntimeException: Unable to start activity ComponentInfo{abc.co.com/com.facebook.accountkit.ui.AccountKitActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class TextView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.facebook.accountkit.ui.LoginFragment.onCreateView(LoginFragment.java:38)
at com.facebook.accountkit.ui.TitleFragmentFactory$TitleFragment.onCreateView(TitleFragmentFactory.java:42)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
at android.app.Activity.performStart(Activity.java:5240)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464)
at android.view.View.<init>(View.java:3787)
at android.widget.TextView.<init>(TextView.java:623)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:59)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:55)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1013)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1072)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at com.facebook.accountkit.ui.LoginFragment.onCreateView(LoginFragment.java:38) 
at com.facebook.accountkit.ui.TitleFragmentFactory$TitleFragment.onCreateView(TitleFragmentFactory.java:42) 
at android.app.Fragment.performCreateView(Fragment.java:1700) 
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890) 
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062) 
at android.app.BackStackRecord.run(BackStackRecord.java:684) 
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447) 
at android.app.Activity.performStart(Activity.java:5240) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 

Exception in Release Mode due to ZipFile

I'm using a code snippet to access a Zip File containing APK file . It works fine in Debug Mode, but, throws Exception in Release Mode.
ZipFile zip = new ZipFile(file);
ZipEntry mft = zip.getEntry("AndroidManifest.xml");
is = zip.getInputStream(mft);
It doesn't make any issue if released in Debug Mode. But, in Release Mode, app gets crashed.
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x418c6c08)
************ 29072016 ************
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vxeed.xnap/com.vxeed.xnap.forms.MainMenu}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.vxeed.xnap.common.ay.a(Unknown Source)
at com.vxeed.xnap.forms.MainMenu.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) 
at android.app.ActivityThread.access$900(ActivityThread.java:175) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
If I get rid of this method, it works fine. Do I need to add anything extra in proguard-rules? Please advise. Thanks in advance

I can't use sharedpreferences without android app crashing

SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = pref.edit();
float highscore = pref.getFloat("highscore",0.0f);
As soon as I enter the activity that uses this part, the app crashes. According to logcat, that first line in this code block gives a nullpointerException. If it's important, this part comes after OnCreate, and I'm using Android Studio.
Logcat:FATAL EXCEPTION: main
Process: com.nonexistent.rs.guessthenumber, PID: 4388
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nonexistent.rs.guessthenumber/com.nonexistent.rs.guessthenumber.main}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:185)
at com.nonexistent.rs.guessthenumber.main.<init>(main.java:141)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) 
at android.app.ActivityThread.access$900(ActivityThread.java:175) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
07-14 10:17:04.616 6030-6030/com.nonexistent.rs.guessthenumber E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nonexistent.rs.guessthenumber, PID: 6030
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nonexistent.rs.guessthenumber/com.nonexistent.rs.guessthenumber.main}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:185)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at com.nonexistent.rs.guessthenumber.main.<init>(main.java:142)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) 
at android.app.ActivityThread.access$900(ActivityThread.java:175) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
Reason:
May be you are using this code from a fragment or on other thread. You Need to pass a activity context reference as an argument. The argument this is the problem.
Solution:
You need to pass the activity / context as the argument
SharedPreferences pref =
PreferenceManager.getDefaultSharedPreferences(Your_Activity_Name.this);
I solved this myself a long time ago, but then I realized that this was left unanswered. Apparently, I'm supposed to put all SharedPrefences code in onCreate.

Android Null Pointer Exception when using Google Places

I am learning android and using an example that uses the places api. My stack trace is as follows.
03-28 22:08:47.228 10687-10687/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.class, PID: 10687
java.lang.RuntimeException: Failure delivering result ResultInfo{who=android:fragment:0, request=1, result=-1, data=Intent { (has extras) }} to activity {com.test.class/com.test.class.MapActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3446)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3489)
at android.app.ActivityThread.access$1300(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.test.class.MapActivity.onPlaceSelected(MapActivity.java:114)
at com.google.android.gms.location.places.ui.PlaceAutocompleteFragment.onActivityResult(Unknown Source)
at android.app.Activity.dispatchActivityResult(Activity.java:5450)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3442)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3489) 
at android.app.ActivityThread.access$1300(ActivityThread.java:139) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5102) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
My code is as show here https://dpaste.de/iOmQ#L114 that is causing the error. Any pointers on what I am doing wrong?
You never assign a value to mPlaceDetailsText. In onCreate(...) you need to add the following line sometime after setContentView(...):
mPlaceDetailsText = (TextView) findViewById(R.id.id_from_layout_file);
and replace R.id.id_from_layout_file with the actual id of the TextView in the map_activity layout file.
Do the same thing for mPlaceAttribution too.

Categories

Resources