0

My app is all right on most of the phone.However,on some kinds of phone,it will get the error below:

android.view.InflateException: Binary XML file line #2: Error inflating class com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1686)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1702)
    at android.app.ActivityThread.access$1600(ActivityThread.java:118)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:952)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3768)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
    at android.view.LayoutInflater.createView(LayoutInflater.java:518)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
    at com.jeremyfeinstein.slidingmenu.lib.app.a.a(Unknown Source)
    at com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity.onCreate(Unknown Source)
    at com.qingdaonews.bus.BaseActivity.onCreate(Unknown Source)
    at com.qingdaonews.activity.MainActivity.onCreate(Unknown Source)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1046)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1650)
    ... 11 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
    at android.view.LayoutInflater.createView(LayoutInflater.java:505)
    ... 21 more
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
    at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
    at android.view.View.(View.java:2096)
    at android.view.ViewGroup.(ViewGroup.java:294)
    at android.widget.RelativeLayout.(RelativeLayout.java:178)
    at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.(Unknown Source)
    at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.(Unknown Source)

And this phone's Android version is 2.3.5 which my app is support(It's fine on other 2.3.5 phones).So I'm confused about that why only this kind of phone will get the error and I don't know how to fix it.
The xml of layout is ver sample:

<?xml version="1.0" encoding="utf-8"?>
<com.jeremyfeinstein.slidingmenu.lib.SlidingMenu xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/slidingmenumain"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" /><br>

And the main class is here jfeinstein10 slidingmenu

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
GuoBuping
  • 63
  • 8

2 Answers2

1

It says you are using some of the API which doesn't exist on 2.3.5. Do you use some attributes of the RelativeLayout in your sliding menu layout which do not exist on previous Android versions? Such as android:layout_alignParentEnd for instance

Pavel Dudka
  • 20,754
  • 7
  • 70
  • 83
  • Thank you.But it's fine on other 2.3.5 phones and I did not use some api over 2.3.5 – GuoBuping Dec 19 '13 at 01:47
  • can you post you sliding menu layout xml file? The problem is obviously there :) – Pavel Dudka Dec 19 '13 at 01:49
  • 1
    I don't see anything wrong here and according to logcat it crashes right in the View's constructor (before these scary layout manipulations from `SlidingMenu` class). So I would assume your device has some custom Android build (not the official one) which throws this exception. I just checked line 2096 of View's implementation in 2.3.5. And it doesn't call `getDimensionPixelSize`, so that's why I assume this is custom build (some CyanogenMod or similar).. – Pavel Dudka Dec 19 '13 at 02:28
  • Thank you very much.It is a custom build but there are many customs use this kind of rom so I wonder the reason of this in order to fix the problem.It is too confused to fix problem in custom build – GuoBuping Dec 19 '13 at 02:35
  • Yeap.. It is really hard to understand what is going on without access to custom rom's `View` implementation. What I would do - is I would play with `width` and `height` params. Try to change it to `match_parent`. Dumb suggestion, I know, but sometimes even dumbest idea work :) – Pavel Dudka Dec 19 '13 at 03:03
  • Thank you.I'll try it. Without dimen the UI performence may be not as good as used but as you say, dumb idea usually works – GuoBuping Dec 19 '13 at 05:28
0

For Android Studio 3.0.1

I have got the same issue and I have resolved finally Opening the gradle.properties and added following line:

android.enableAapt2=false

Shahid Aslam
  • 2,585
  • 3
  • 24
  • 31