Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NumberFormatException: Invalid int: "res/drawable/title_bar.xml"

I got strange error in developer console:

java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package/my.package.Main}: java.lang.NumberFormatException: Invalid int: "res/drawable/title_bar.xml"
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
at android.app.ActivityThread.access$1500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4025)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NumberFormatException: Invalid int: "res/drawable/title_bar.xml"
at java.lang.Integer.invalidInt(Integer.java:129)
at java.lang.Integer.parse(Integer.java:366)
at java.lang.Integer.parseInt(Integer.java:357)
at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:123)
at android.content.res.TypedArray.getInt(TypedArray.java:254)
at android.view.animation.Animation.<init>(Animation.java:244)
at android.view.animation.ScaleAnimation.<init>(ScaleAnimation.java:63)
at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:118)
at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:91)
at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:72)
at my.package.FragmentGameType.onActivityCreated(FragmentGameType.java:111)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1468)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:931)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1132)
at android.app.Activity.performStart(Activity.java:4371)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1721)
... 11 more

this is the code of FragmentGameType.java:

110. animZoomIn = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_in);
111. animZoomOut = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_out);
112. animZoomInRot = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_in_rot);
113. animZoomOutRot = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_out_rot);

Does anyone have any ideas?

like image 313
embo Avatar asked Nov 12 '22 09:11

embo


1 Answers

Try to review you animations xml files,

I had similar crash when test my code in android 2.3, the problem was the animation definition of some sentence, look lines, such as:

android:fromXScale="1%"

android:toXScale="100%"

fromXScale,toXScale needs a float parameter, don’t like "100%", for that, in API level 10 I received java.lang.NumberFormatException. It is no supported for API 10, however in higher It work well, that creates confusion.

I changed the code for:

android:fromXScale="0.1"

android:toXScale="1.0

And problem solved.

like image 189
Campino Avatar answered Nov 15 '22 11:11

Campino