Illegal Argument
Illegal Argument

Reputation: 10338

Map Fragment not working in Android4.4 kitkat

I am facing a wierd problem in Android kitkat. I am not able to use map fragments(support map fragment too). I used the following code:

<fragment
    android:id="@+id/fragment1"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_above="@+id/imageView1"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/linearLayout1" />

My application works in api level 18(Jellybean) but when compiled with kitkat it gives the following error: Error inflating class fragment!

Logcat output:

11-14 07:12:12.039: E/AndroidRuntime(1068):     at dalvik.system.NativeStart.main(Native Method)

11-14 07:12:12.039: E/AndroidRuntime(1068): Caused by: android.view.InflateException: Binary XML file line #96: Error inflating class fragment

11-14 07:12:12.039: E/AndroidRuntime(1068):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)

11-14 07:12:12.039: E/AndroidRuntime(1068):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)

11-14 07:12:12.039: E/AndroidRuntime(1068):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)

11-14 07:12:12.039: E/AndroidRuntime(1068):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

11-14 07:12:12.039: E/AndroidRuntime(1068):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)

Upvotes: 1

Views: 1560

Answers (2)

Illegal Argument
Illegal Argument

Reputation: 10338

Solved the problem by adding the following line to the manifest file as a direct element of the application tag this was probably enforced after the new google play services was launched:

<meta-data android:name="com.google.android.gms.version"
   android:value="@integer/google_play_services_version" />

Also a note to fellow developers make sure you extend your activity with FragmentActivity.

Upvotes: 0

Gianluca P.
Gianluca P.

Reputation: 1551

on nexus 5 device there are incompatible support and play services libraries, if you are using them in your project (either in libs for support-v4 or project libraries for the others) you can delete the related <uses-library ... /> tags from AndroidManifest.xml since the necessary bytecode should already be included in your app.
Doing this fixed the problem for me: I was actually using the fragment programmatically and getting a "caused by":

java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

Upvotes: 2

Related Questions