Android Application working in Android 2 but throws exception in Android 4


Ask by : user1753461 October 11, 2013 06:14

I have an android app that runs good in Android 2 , but when I try to run it on Android 4,it crashes and throws exceptions. Bellow is the Log I get

11-04 16:50:01.015: E/AndroidRuntime(753): FATAL EXCEPTION: main 11-04
 16:50:01.015: E/AndroidRuntime(753): java.lang.RuntimeException:
 Unable to start activity
 ComponentInfo{com.example.huda.elklob/com.example.huda.elklob.options}:
 android.view.InflateException: Binary XML file line #22: Error
 inflating class android.widget.Button 11-04 16:50:01.015:
 E/AndroidRuntime(753):     at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.app.ActivityThread.access$600(ActivityThread.java:123) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.os.Handler.dispatchMessage(Handler.java:99) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.os.Looper.loop(Looper.java:137) 11-04 16:50:01.015:
 E/AndroidRuntime(753):     at
 android.app.ActivityThread.main(ActivityThread.java:4424) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 java.lang.reflect.Method.invokeNative(Native Method) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 java.lang.reflect.Method.invoke(Method.java:511) 11-04 16:50:01.015:
 E/AndroidRuntime(753):     at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 dalvik.system.NativeStart.main(Native Method) 11-04 16:50:01.015:
 E/AndroidRuntime(753): Caused by: android.view.InflateException:
 Binary XML file line #22: Error inflating class android.widget.Button
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.view.LayoutInflater.createView(LayoutInflater.java:606) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.view.LayoutInflater.inflate(LayoutInflater.java:489) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.view.LayoutInflater.inflate(LayoutInflater.java:396) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.view.LayoutInflater.inflate(LayoutInflater.java:352) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.app.Activity.setContentView(Activity.java:1835) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 com.example.huda.elklob.options.onCreate(options.java:17) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.app.Activity.performCreate(Activity.java:4465) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
 11-04 16:50:01.015: E/AndroidRuntime(753):     ... 11 more 11-04
 16:50:01.015: E/AndroidRuntime(753): Caused by:
 java.lang.reflect.InvocationTargetException 11-04 16:50:01.015:
 E/AndroidRuntime(753):     at
 java.lang.reflect.Constructor.constructNative(Native Method) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 java.lang.reflect.Constructor.newInstance(Constructor.java:417) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.view.LayoutInflater.createView(LayoutInflater.java:586) 11-04
 16:50:01.015: E/AndroidRuntime(753):   ... 25 more 11-04 16:50:01.015:
 E/AndroidRuntime(753): Caused by: java.lang.OutOfMemoryError 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
 11-04 16:50:01.015: E/AndroidRuntime(753):     at
 android.content.res.Resources.loadDrawable(Resources.java:1935) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.content.res.TypedArray.getDrawable(TypedArray.java:601) 11-04
 16:50:01.015: E/AndroidRuntime(753):   at
 android.view.View.<init>(View.java:2785) 11-04 16:50:01.015:
 E/AndroidRuntime(753):     at
 android.widget.TextView.<init>(TextView.java:449) 11-04 16:50:01.015:
 E/AndroidRuntime(753):     at
 android.widget.Button.<init>(Button.java:108) 11-04 16:50:01.015:
 E/AndroidRuntime(753):     at
 android.widget.Button.<init>(Button.java:104) 11-04 16:50:01.015:
 E/AndroidRuntime(753):     ... 28 more

Can anyone help?

View original question

Answer by : Seva AlekseyevNovember 04, 2012 15:27

Yech. Next time, please format your LogCat dump as "code" as opposed to "quote". At least the line breaks will be in their rightful places.

That said, the relevant bit is here:

Caused by: java.lang.OutOfMemoryError
11-04 16:50:01.015: E/AndroidRuntime(753): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
11-04 16:50:01.015: E/AndroidRuntime(753): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)

Out of memory error while decoding a bitmap. Make it a smaller bitmap.

View original answer