I have app that has map in the second menu in drawerlayout. When i try to inflate the fragment with map the app crashes.
Following is the code:
if (rootView != null) {
ViewGroup parent = (ViewGroup) rootView.getParent();
if (parent != null) {
parent.removeView(rootView);
}
}
try {
rootView = inflater.inflate(R.layout.fragment_map, container, false);
} catch (Exception e) {
e.printStackTrace();
}
Following is the exception generated:
android.view.InflateException: Binary XML file line #23: Error inflating class fragment
I've tried many solutions on stack and other platforms but in vain.
This is how i am using map fragment within parent RelativeLayout in my xml:
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
I also tried removing the map fragment in its onDestroyView
methos:
@Override
public void onDestroyView() {
super.onDestroyView();
SupportMapFragment fragment = ((SupportMapFragment) getChildFragmentManager()
.findFragmentById(R.id.map));
try{
if (fragment != null)
getChildFragmentManager().beginTransaction().remove(fragment).commit();
}catch(Exception e){
}
}
Following is the manifest file data:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.app.myapp.SplashActivity"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:label="@string/app_name"
android:noHistory="true"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.app.myapp.LoginActivity"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"
>
</activity>
<activity
android:name="com.app.myapp.MainActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name" >
</activity>