I found similar topics in stackoverflow but it didn't help for me. I am showing google map using fragment and it crashes after get another fragment and come back. In other words, google map shows only once and crashes. Here are the codes.
public class MapTabMainFragment extends BaseFragment {
private AdView adView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = null;
try {
view = inflater.inflate(R.layout.fragment_map_main, container,
false);
} catch (Exception e) {
e.printStackTrace();
}
initComponents(view);
initValues();
initListeners();
return view;
}
public void initComponents(View view) {
adView = (AdView) view.findViewById(R.id.adView1);
}
public void initValues() {
AdRequest re = new AdRequest();
adView.loadAd(re);
}
public void initListeners() {
}
}
public class BaseFragment extends Fragment {
public BottomTabActivity mActivity;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mActivity = (BottomTabActivity) this.getActivity();
}
public boolean onBackPressed() {
return false;
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
when I try to catch the exception, it is
android.view.InflateException: Binary XML file line #20: Error inflating class fragment.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/WhiteColor"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/header" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/data_listview_margin_top" >
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/data_listview_margin_bottom"
class="com.google.android.gms.maps.SupportMapFragment" />
<!--class="com.cyrilmottier.polaris2.maps.SupportMapFragment" -->
<com.google.ads.AdView
android:id="@+id/adView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:adSize="SMART_BANNER"
app:adUnitId="ca-app-pub-9766031373541061/3761995838"
app:loadAdOnCreate="true"
app:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" >
</com.google.ads.AdView>
</RelativeLayout>
</LinearLayout>