Receiving Reports Form Users Of java.lang.OutOfMemoryError
I've been having reports from my users of force closing on start-up and
crashes on my latest release of my application.
I think ive pinpointed the problem to my theming in my preferences. The
problem is, cannot figure out what the problem is...
Here is my code for theming my application:
ImageButton ibStopwatch = (ImageButton) findViewById(R.id.ibStopwatch);
ImageButton ibFs = (ImageButton) findViewById(R.id.ibFs);
ImageButton ibFsn = (ImageButton) findViewById(R.id.ibFsn);
ImageButton ibMusic = (ImageButton) findViewById(R.id.ibMusic);
ImageButton ibYoutube = (ImageButton) findViewById(R.id.ibYoutube);
ImageButton ibPlay = (ImageButton) findViewById(R.id.ibPlay);
ImageButton ibSearch = (ImageButton) findViewById(R.id.ibSearch);
ImageButton ibBrowser = (ImageButton) findViewById(R.id.ibBrowser);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl);
ViewFlipper vf = (ViewFlipper) findViewById(R.id.vf);
String theme = prefs.getString("Theme", "1");
if (theme.contentEquals("1")) {
tvTime.setTextColor(Color.parseColor("#CCCCCC"));
tvAmPm.setTextColor(Color.parseColor("#CCCCCC"));
tvDate.setTextColor(Color.parseColor("#CCCCCC"));
tvAlarm.setTextColor(Color.parseColor("#CCCCCC"));
tvBat.setTextColor(Color.parseColor("#CCCCCC"));
rl.setBackgroundColor(Color.parseColor("#222222"));
vf.setDisplayedChild(0);
ibStopwatch.setBackgroundResource(R.drawable.stopwatch);
ibFs.setBackgroundResource(R.drawable.fs);
ibFsn.setBackgroundResource(R.drawable.fsnm);
ibMusic.setBackgroundResource(R.drawable.music);
ibYoutube.setBackgroundResource(R.drawable.youtube);
ibPlay.setBackgroundResource(R.drawable.play);
ibSearch.setBackgroundResource(R.drawable.search);
ibBrowser.setBackgroundResource(R.drawable.browser);
}
if (theme.contentEquals("2")) {
tvTime.setTextColor(Color.RED);
tvAmPm.setTextColor(Color.RED);
tvDate.setTextColor(Color.RED);
tvAlarm.setTextColor(Color.RED);
tvBat.setTextColor(Color.RED);
rl.setBackgroundColor(Color.parseColor("#180000"));
vf.setDisplayedChild(1);
ibStopwatch.setBackgroundResource(R.drawable.stopwatchred);
ibFs.setBackgroundResource(R.drawable.fsred);
ibFsn.setBackgroundResource(R.drawable.fsnmred);
ibMusic.setBackgroundResource(R.drawable.musicred);
ibYoutube.setBackgroundResource(R.drawable.youtubered);
ibPlay.setBackgroundResource(R.drawable.playred);
ibSearch.setBackgroundResource(R.drawable.searchred);
ibBrowser.setBackgroundResource(R.drawable.browserred);
}
if (theme.contentEquals("3")) {
tvTime.setTextColor(Color.GREEN);
tvAmPm.setTextColor(Color.GREEN);
tvDate.setTextColor(Color.GREEN);
tvAlarm.setTextColor(Color.GREEN);
tvBat.setTextColor(Color.GREEN);
rl.setBackgroundColor(Color.parseColor("#001800"));
vf.setDisplayedChild(2);
ibStopwatch.setBackgroundResource(R.drawable.stopwatchgreen);
ibFs.setBackgroundResource(R.drawable.fsgreen);
ibFsn.setBackgroundResource(R.drawable.fsnmgreen);
ibMusic.setBackgroundResource(R.drawable.musicgreen);
ibYoutube.setBackgroundResource(R.drawable.youtubegreen);
ibPlay.setBackgroundResource(R.drawable.playgreen);
ibSearch.setBackgroundResource(R.drawable.searchgreen);
ibBrowser.setBackgroundResource(R.drawable.browsergreen);
}
if (theme.contentEquals("4")) {
tvTime.setTextColor(Color.BLUE);
tvAmPm.setTextColor(Color.BLUE);
tvDate.setTextColor(Color.BLUE);
tvAlarm.setTextColor(Color.BLUE);
tvBat.setTextColor(Color.BLUE);
rl.setBackgroundColor(Color.parseColor("#000018"));
vf.setDisplayedChild(3);
ibStopwatch.setBackgroundResource(R.drawable.stopwatchblue);
ibFs.setBackgroundResource(R.drawable.fsblue);
ibFsn.setBackgroundResource(R.drawable.fsnmblue);
ibMusic.setBackgroundResource(R.drawable.musicblue);
ibYoutube.setBackgroundResource(R.drawable.youtubeblue);
ibPlay.setBackgroundResource(R.drawable.playblue);
ibSearch.setBackgroundResource(R.drawable.searchblue);
ibBrowser.setBackgroundResource(R.drawable.browserblue);
}
This is for my main activity where most of the errors happen.
I find that sometimes when I change the theme in my preferences Activity
and press back which calls finish() when I enter preferences and the
launches my main activity when i press back to refresh the layout and
resources etc.
The problem could be to do with excessive use and changing of resources
may be causing it to crash. The crashing, for me, is random after changing
themes.
This is the stack trace I am given in the developer console:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.timmo.clock/com.timmo.clock.DeskClock}:
android.view.InflateException: Binary XML file line #156: Error inflating
class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296)
at android.app.ActivityThread.access$700(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5293)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #156: Error
inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:327)
at android.app.Activity.setContentView(Activity.java:1928)
at com.timmo.clock.DeskClock.onCreate(DeskClock.java:77)
at android.app.Activity.performCreate(Activity.java:5250)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:593)
... 25 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
at
android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at
android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:817)
at android.content.res.Resources.loadDrawable(Resources.java:2854)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.AnalogClock.<init>(AnalogClock.java:88)
at android.widget.AnalogClock.<init>(AnalogClock.java:67)
... 28 more
As I struggle to read stacks I hope someone can help me figure out my
problem and hopefully I can get this bug fixed instead of wiping the
feature completely...
Thanks
No comments:
Post a Comment