Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error inflating class fragment for SupportMapFragment

I have a SupportMapFragment being used and in every device i've tested it on it has worked fine. I got an error report for a java.io.FileNotFoundException with the following:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.koosprozinski.westernwheels/com.koosprozinski.westernwheels.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2098)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4945)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:408)
at android.app.Activity.setContentView(Activity.java:2050)
at com.koosprozinski.westernwheels.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:5202)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2037)
... 11 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/maps_btn_myl.xml from drawable resource ID #0x7f020115
at android.content.res.Resources.loadDrawable(Resources.java:1957)
at android.content.res.Resources.getDrawable(Resources.java:673)
at maps.ai.a.c(Unknown Source)
at maps.af.al.a(Unknown Source)
at maps.af.be.a(Unknown Source)
at maps.af.bd.a(Unknown Source)
at cmi.onTransact(SourceFile:107)
at android.os.Binder.transact(Binder.java:326)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
at com.google.android.gms.dynamic.a$4.b(Unknown Source)
at com.google.android.gms.dynamic.a.a(Unknown Source)
at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
... 21 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi-v14/maps_btn_myl_pressed.png from drawable resource ID #0x7f020117
at android.content.res.Resources.loadDrawable(Resources.java:1974)
at android.content.res.Resources.getDrawable(Resources.java:673)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:818)
at android.content.res.Resources.loadDrawable(Resources.java:1954)
... 40 more
Caused by: java.io.FileNotFoundException: res/drawable-hdpi-v14/maps_btn_myl_pressed.png
at android.content.res.AssetManager.openNonAssetNative(Native Method)
at android.content.res.AssetManager.openNonAsset(AssetManager.java:407)
at android.content.res.Resources.loadDrawable(Resources.java:1966)
... 45 more

Here is my main activity 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="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

What exactly could be causing this? As far as I am aware, the vast majority of users are not experiencing this and I can't think of any way to try and replicate it.

like image 576
Koosc2 Avatar asked Nov 18 '13 00:11

Koosc2


3 Answers

Try the following, it worked for me:

<application>    
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="API KEY" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
</application>
like image 103
Valleyman Avatar answered Oct 30 '22 23:10

Valleyman


And here is the solution! NullPointerException from Google maps Insert the SD card if you don't have an internal one! Google din't fix that problem since 2013.

like image 26
halxinate Avatar answered Oct 31 '22 01:10

halxinate


I suggest you to make like this:

<fragment
    android:id="@+id/map"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />  

Not android:name. Let me know if it works.

like image 27
Blo Avatar answered Oct 31 '22 01:10

Blo