14

I have these log errors when launching my app:

> 05-20 01:48:35.312: E/AndroidRuntime(23032): FATAL EXCEPTION: main
05-20 01:48:35.312: E/AndroidRuntime(23032): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tomsyweb.suna/com.tomsyweb.suna.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class com.origamilabs.library.views.StaggeredGridView
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.os.Looper.loop(Looper.java:130)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.app.ActivityThread.main(ActivityThread.java:3687)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at java.lang.reflect.Method.invokeNative(Native Method)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at java.lang.reflect.Method.invoke(Method.java:507)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at dalvik.system.NativeStart.main(Native Method)
05-20 01:48:35.312: E/AndroidRuntime(23032): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.origamilabs.library.views.StaggeredGridView
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.view.LayoutInflater.createView(LayoutInflater.java:518)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at com.tomsyweb.suna.MainActivity.onCreate(MainActivity.java:72)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
05-20 01:48:35.312: E/AndroidRuntime(23032):    ... 11 more
05-20 01:48:35.312: E/AndroidRuntime(23032): Caused by: java.lang.reflect.InvocationTargetException
05-20 01:48:35.312: E/AndroidRuntime(23032):    at java.lang.reflect.Constructor.constructNative(Native Method)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at android.view.LayoutInflater.createView(LayoutInflater.java:505)
05-20 01:48:35.312: E/AndroidRuntime(23032):    ... 21 more
05-20 01:48:35.312: E/AndroidRuntime(23032): Caused by: java.lang.NoClassDefFoundError: android.support.v4.util.SparseArrayCompat
05-20 01:48:35.312: E/AndroidRuntime(23032):    at com.origamilabs.library.views.StaggeredGridView.<init>(StaggeredGridView.java:297)
05-20 01:48:35.312: E/AndroidRuntime(23032):    at com.origamilabs.library.views.StaggeredGridView.<init>(StaggeredGridView.java:304)
05-20 01:48:35.312: E/AndroidRuntime(23032):    ... 24 more

And the problem appeared just after installing Android SDK Tools Rev. 22, Android SDK Build-tools and updating Google Play Services.

Whereas in this error

Caused by: java.lang.NoClassDefFoundError: android.support.v4.util.SparseArrayCompat

and noting that for all "android.support.v4" import, the Javadoc isn't accessible

Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

the problem is probably due to the Android support library.

Hope all this information will help you find a solution.

Sunil Kumar
  • 7,086
  • 4
  • 32
  • 50
tsil
  • 2,069
  • 7
  • 29
  • 43
  • possible duplicate of [Libraries do not get added to APK anymore after upgrade to ADT 22](http://stackoverflow.com/questions/16596969/libraries-do-not-get-added-to-apk-anymore-after-upgrade-to-adt-22) – tc. May 20 '13 at 15:34
  • 1
    most of the answers for eclipse. anyone give good solution for android studio – Ranjithkumar Sep 13 '17 at 12:08
  • it happened for me in android studio, when my target sdk is 28, and running emulator api level 15, throws this error – mochadwi Feb 18 '20 at 15:46

6 Answers6

40

Right Click on your project -> Build Path -> Configure Build Path -> Order and Export Tab.

Make sure that "Android Private Libraries" is checked for Export.

If you've added any libraries from the libs/ folder, remove them as they are automatically added in the "Android Private Libraries" section.

Vinay S Shenoy
  • 4,028
  • 3
  • 31
  • 36
1

I always get this and just restart eclipse to resolve it on MAC laptop.

j2emanue
  • 60,549
  • 65
  • 286
  • 456
1

While your compile version is not the same with your Minimum Required SDK Version,android will create appcompat,the appcompat created may reference it's own support-v4,and the support-v4 version may be different with the support-v7 you have used,even you have an compatible support-v4. I solved this problem just to have Minimum Required SDK version be same with compile version. Wish to help everyone.

bozzmob
  • 12,364
  • 16
  • 50
  • 73
xiangfei
  • 11
  • 1
0

right click on the project - properties - java build path - Order and export - tick Android private libraries and all the libraries that u added

Chris Sim
  • 4,054
  • 4
  • 29
  • 36
0

Solutions:

  • List item
  • Check Exports Order
  • Enable Multi Dex
  • Check api level of views in layout. I faced same problem with searchView. I have check api level while adding searchview but added implements SearchView.OnQueryTextListener to class file.
  • Check support Libraries v4,v7 etc
0

You might wanna check from official android documentation.

I've occurred this error below when running my apps to my minimum SDK (15):

Fatal Exception: java.lang.NoSuchMethodError: android.util.LongSparseArray.removeAt

After reading actual android documentation here: https://developer.android.com/reference/android/util/LongSparseArray (sadly only added in API Level 16)

If you using 3rd-party libraries (in my case, I'm using Chuck), you might wanna ask them about supporting your minimum level SDK API. Otherwise, increase your minimum SDK to match the minimum API library had or do this (not recommended, will crash your apps)

// AndroidManifest
<manifest 
  <uses-sdk tools:overrideLibrary="com.readystatesoftware.chuck, your.another.package.here" />

  <application>
  // ommited...
  </application>
</manifest
mochadwi
  • 1,190
  • 9
  • 32
  • 87