Bad magic number for Bundle: 0x6f0063 SupportMapFragment - android

I have this issue on Android 5.1.1 (OPPO phone)
Fatal Exception: java.lang.IllegalStateException: Bad magic number for Bundle: 0x6f0063
at android.os.BaseBundle.readFromParcelInner(BaseBundle.java:1346)
at android.os.BaseBundle.readFromParcelInner(BaseBundle.java:1334)
at android.os.Bundle.readFromParcel(Bundle.java:1046)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onResume(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$zza.onResume(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onSaveInstanceState(Unknown Source:6000)
at android.support.v4.app.Fragment.performSaveInstanceState(Fragment.java:2353)
at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:2599)
at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2670)
at android.support.v4.app.FragmentController.saveAllState(FragmentController.java:134)
at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:571)
at android.support.v7.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:509)
It is hard to re-produce, but it almost occured on OPPO phone Android 5.1.1.
Maybe it related to this issue
https://issuetracker.google.com/issues/37011984
Any workarround to fix it? Thanks in advance.
This is a part of activity xml
<fragment
android:id="#+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
onCreate activity
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);

Related

Google Maps doesn´t work on Galaxy s3 with 4.03

I am working on an AVD with the specs of a Galaxy S6. There I can use the SupportMapFragment without problems.
But when a customer tries to use the App including the Map on a Galaxy S3 Device with 4.9" and Android Version 4.03, the App doesn't show the Map.
What can I do?
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ibas.locatixteamviewer.MapsActivity">
<!--<Button-->
<!--android:id="#+id/button1"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:background="#359c5e"-->
<!--android:layout_alignParentTop="true"-->
<!--android:layout_alignParentEnd="true"-->
<!--android:padding="8dp"-->
<!--android:layout_margin="5dp"-->
<!--android:src="#drawable/menu_car_side_7_white"-->
<!--android:textColor="#ffffff" />-->
</fragment>
//----------------------------
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Thanks!

SupportMapFragment not showing Google Logo

I am using SupportMapFragment to display Google Maps in my app:
SupportMapFragment mMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);
if (mMapFragment == null) {
mMapFragment = new SupportMapFragment();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.map_frame, mMapFragment, MAP_FRAGMENT_TAG).commit();
}
mMapFragment.getMapAsync(this);
This is the xml part:
<FrameLayout
android:id="#+id/map_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/button_status_view">
</FrameLayout>
Unfortunately, the map doesn't show the Google logo which causes violation on the Google Maps APIs terms of service (https://developers.google.com/maps/terms) In particular clause 9.4(a), which does not allow developers to delete or alter the Google logo on the map displayed in your app.
How can I add the Google logo to the map? Should it be there by default? Am I missing something? The fragment currently shows only the GPS button.
use MapFragment instead of Frame Layout:
<fragment android:id="#+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.googlemapdemo.MapsActivity"/>

Google maps v2 on android devices with minSDK below 11

i have problem with this line when I create project which use Google maps API v2.
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
It's says that I need to set minSDK to be minimum 11, but I want to use this application also on devices with android minSDK 8 (2.3.3). Any ideas? Or simply: How I can set google maps API v2 to be compatible with devices with minSDK 8.
Thanks
Use SupportMapFragment from a FragmentActivity, instead of MapFragment from an Activity. To use fragments on devices older than API Level 11, you need to use the Android Support package's backport of fragments (where FragmentActivity comes from).
http://android-er.blogspot.de/2012/12/using-supportmapfragment.html - small example
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world" />
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
AND:
package de.meinprospekt.android.ui;
import java.text.SimpleDateFormat;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Fragment fragment = getSupportFragmentManager().findFragmentById(
R.id.map);
SupportMapFragment mapFragment = (SupportMapFragment) fragment;
GoogleMap mMap = mapFragment.getMap();

Using geo location Google maps api v2

I have added a map fragment to my app including a geographic marker and included my play services jar but I'm getting the following error on my marker code:
Error: Cannot cast from Fragment to SupportMapFragment
The snippet is as follows:
GoogleMap mMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.addMarker(new MarkerOptions()
.position(new LatLng(53.271900177, -9.04889965057))
.title("GMI alway Location"));;
This is my xml declaration to reference it:
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
Anyone have any ideas as to where I'm going wrong? Thanks Brian J
You have to use the SupportFragmentManager and the FragmentActivity classes if you are using the SupportMapFragment in your layout.
So use the getSupportFragmentManager() method instead of getFragmentManager().

GoogleMap class object throw Nullpointer Exception

friends, I am getting NullPointer error ,on addMarker()
Below is my sample code.
GoogleMap myMap;
android.support.v4.app.FragmentManager myFragmentManager = getSupportFragmentManager();
SupportMapFragment myMapFragment = (SupportMapFragment)myFragmentManager.findFragmentById(R.id.map);
myMap = myMapFragment.getMap();
myMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
myMap.setMyLocationEnabled(true);
myMap.getUiSettings().setZoomControlsEnabled(true);
myMap.getUiSettings().setCompassEnabled(true);
myMap.getUiSettings().setMyLocationButtonEnabled(true);
Error message like NullPointer at line
myMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".DemoMapActiviy" >
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
any idea how can i solve it?
I went through this issue a while back. First check to see if your fragment is found by the fragment manager.
If not try replacing the way you've put your fragment into your view. If you want an example of another way I've posted a maps example here
Any more questions feel free to comment and I'll work through it with you :)
EDIT
have you got the correct API key in there? If you can't contact Google's servers then there's a good chance that that's your problem. Otherwise may be a manifest issue make sure you have READ_GSERVICES and INTERNET permissions.
See Google Maps API V2 'Failed to Load Map. Could not contact Google Servers'
Edit 2
Ok so I was being lazy before and just referring you to my project. If you were getting a connection to maps in your project lets start from there.
What I was suggesting in my original response was to check and see if myMapFragment was null. If it is great try doing something along the lines of the following:
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
SupportMapFragment myMapFragment = new SupportMapFragment();
ft.replace(R.id.map, myMapFragment, Constant.TAXI_FRAGMENT_ID);
ft.commit();
Where R.id.map is an empty FrameLayout
If myMapFragment isn't null then try extending SupportMapFragment and running the following test:
public class MyMapFragment extends SupportMapFragment {
#Override
public void onActivityCreated()
{
if (getMap() == null) Log.e("TAG", "There's something very wrong here";
}
}
Also if you do this make sure that you are inflating an instance of MyMapFragment not of SupportMapFragment

Categories

Resources