Question

I have some problem. when I change any xml-file, I get error on main layout initialization (I sure only about small layouts). For example, if I add one more field on the setup-wizard fragment, I got that error:

09-15 20:33:49.697: E/AndroidRuntime(3529): FATAL EXCEPTION: main
09-15 20:33:49.697: E/AndroidRuntime(3529): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.linphone/org.linphone.LinphoneActivity}: android.view.InflateException: Binary XML file line #81: Error inflating class fragment
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.os.Looper.loop(Looper.java:130)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.app.ActivityThread.main(ActivityThread.java:3687)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at java.lang.reflect.Method.invokeNative(Native Method)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at java.lang.reflect.Method.invoke(Method.java:507)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at dalvik.system.NativeStart.main(Native Method)
09-15 20:33:49.697: E/AndroidRuntime(3529): Caused by: android.view.InflateException: Binary XML file line #81: Error inflating class fragment
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.app.Activity.setContentView(Activity.java:1657)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at org.linphone.LinphoneActivity.onCreate(LinphoneActivity.java:151)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
09-15 20:33:49.697: E/AndroidRuntime(3529):     ... 11 more
09-15 20:33:49.697: E/AndroidRuntime(3529): Caused by: java.lang.ClassCastException: android.widget.ImageView
09-15 20:33:49.697: E/AndroidRuntime(3529):     at org.linphone.StatusFragment.onCreateView(StatusFragment.java:80)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:846)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1160)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
09-15 20:33:49.697: E/AndroidRuntime(3529):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
09-15 20:33:49.697: E/AndroidRuntime(3529):     ... 21 more

Where I can take some info about what I am doing wrong?

UPDATE 1

line 80 in StatusFragment.java

statusText = (TextView) view.findViewById(R.id.statusText);

And it's really TextView. Moreover I even don't touch that files.

To Beginner:

You can take code from git:

git clone git://git.linphone.org/linphone-android.git

if you want whole project, ready to build, use --recursive tag.

Was it helpful?

Solution

Go to Project->Clean in Eclipse, let it finish then run your application again, everything will work.

Eclipse caches your resource IDs based on the order of your views in the layout. If you change that around it is possible to get a classcastexception. Cleaning your project forces Eclipse to re-cache all your IDs properly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top