I am using DrawerNavigator in my app.
I created an android app which works perfectly with android 4.2 but when I try to launch it in android 2.2 I get this error:
android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
at android.widget.AbsListView.obtainView(AbsListView.java:1582)
at android.widget.ListView.makeAndAddView(ListView.java:1801)
at android.widget.ListView.fillDown(ListView.java:724)
at android.widget.ListView.fillFromTop(ListView.java:781)
at android.widget.ListView.layoutChildren(ListView.java:1638)
at android.widget.AbsListView.onLayout(AbsListView.java:1412)
at android.view.View.layout(View.java:7175)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:672)
at android.view.View.layout(View.java:7175)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7175)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7175)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7175)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7175)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1146)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1866)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
EDIT: these lines are also in there:
07-22 16:00:52.111: E/AndroidRuntime(470): Caused by: android.content.res.Resources$NotFoundException: File res/color/abs__primary_text_holo_light.xml from xml type drawable resource ID #0x0
07-22 16:00:52.111: E/AndroidRuntime(470): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1924)
07-22 16:00:52.111: E/AndroidRuntime(470): at android.content.res.Resources.loadDrawable(Resources.java:1692)
07-22 16:00:52.111: E/AndroidRuntime(470): ... 42 more
I cant figure out why.
I am calling my fragment (ShelrockFragment) from MainActivity :
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, newsMasterFragment, "MasterFragment");
bundle.putBoolean("onFirstRow", true);
newsMasterFragment.setArguments(bundle);
and it crashes when inflating the view:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_news_master,
container, false);
In case anybody has the same problem the issue was the android:background
android:background="?android:attr/activatedBackgroundIndicator"
crushed the whole app. So I removed it in the pre-Honeycomb versions
It's because Fragments API was introduced in Android 3.0 (API level 11).
If you want to use them in Android 2.2 (API level 8), you have to use compatibility libraries provided by Google. How to do it, you can read for example here: Fragments in Android 2.2.1, 2.3, 2.0. Is this possible?
In drawer_list_item.xml file
remove android:background="?android:attr/activatedBackgroundIndicator" line
if you want background change with html color code.
Related
I added the admob adview from xml like this;
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_above="#id/footerContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="..."
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR" />
First; there seems to be no problem. But when i change the orientation of the screen a couple of times quickly; the app crashed. I have these errors;
1- bitmap size exceeds VM budget
java.lang.OutOfMemoryError: bitmap size exceeds VM budget at
android.graphics.Bitmap.nativeCreate(Native Method) at
android.graphics.Bitmap.createBitmap(Bitmap.java:477) at
android.graphics.Bitmap.createBitmap(Bitmap.java:444) at
android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349) at
android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:498) at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:473) at
android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
at
android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1785) at
android.content.res.TypedArray.getDrawable(TypedArray.java:601) at
android.widget.ImageView.(ImageView.java:118) at
android.widget.ImageButton.(ImageButton.java:85) at
android.widget.ImageButton.(ImageButton.java:81) at
java.lang.reflect.Constructor.constructNative(Native Method) at
java.lang.reflect...
2- Binary XML file line #16: Error inflating class
android.view.InflateException: Binary XML file line #16: Error
inflating class at
android.view.LayoutInflater.createView(LayoutInflater.java:518) at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) at
android.view.LayoutInflater.inflate(LayoutInflater.java:408) at
android.view.LayoutInflater.inflate(LayoutInflater.java:320) at
android.view.LayoutInflater.inflate(LayoutInflater.java:276) at
com.X.ui.FooterFragment.onCreateView(FooterFragment.java:21) at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:846)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:...
3- Unable to start activity
ComponentInfo{com.x/com.x.ui.HomeActivity}:
android.view.InflateException: Binary XML file line #13: Error
inflating class
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.X/com.X.ui.HomeActivity}:
android.view.InflateException: Binary XML file line #13: Error
inflating class at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
at
android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2953)
at android.app.ActivityThread.access$1600(ActivityThread.java:123) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:943) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:130) at
android.app.ActivityThread.main(ActivityThread.java:3835) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:507) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(Zygo.
I tried adding it programmatically as described here, but nothing changed... Any ideas?
For 1, what SDK version are you using, and what device are you running it on? This may be an emulator specific issue.
2 and 3 are likely due to not linking the AdMob library correctly. See Error inflating class com.google.ads.AdView.
everybody!
I got such situation: I have a layout with some views and a listView. A question is: is it possible to take those views (from the layout where listview is situated) and set them as a header to this listview?
By now I tried:
LinearLayout header = (LinearLayout)getView().findViewById(R.id.header);
listView.addHeaderView(header, null, true);
This gives me an error:
ERROR/AndroidRuntime(18913): FATAL EXCEPTION: main
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
at android.widget.ListView.clearRecycledState(ListView.java:553)
at android.widget.ListView.resetList(ListView.java:539)
at android.widget.ListView.layoutChildren(ListView.java:1477)
at android.widget.AbsListView.onLayout(AbsListView.java:1407)
at android.view.View.layout(View.java:7314)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7314)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7314)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
at android.view.View.layout(View.java:7314)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
at android.view.View.layout(View.java:7314)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7314)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7314)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7314)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1180)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1900)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
I have a Galaxy Samsung tab 10.1" Model GT-P7510 OS Version 3.2. I tried to load app on it and it's giving me Layout inflater error. Why is this? Here is what logcat says:
android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:596)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:245)
at android.app.Activity.setContentView(Activity.java:1786)
at com.businessplan.BusinessPlannerActivity.onCreate(BusinessPlannerActivity.java:64)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1782)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1834)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1027)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4126)
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:844)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:416)
at android.view.LayoutInflater.createView(LayoutInflater.java:576)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020022 a=-1 r=0x7f020022}
at android.content.res.Resources.loadDrawable(Resources.java:1890)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:2462)
at android.view.ViewGroup.<init>(ViewGroup.java:365)
at android.widget.LinearLayout.<init>(LinearLayout.java:156)
at android.widget.LinearLayout.<init>(LinearLayout.java:152)
Probably you have an error in the layout file called here:
android.app.Activity.setContentView(Activity.java:1786) at com.businessplan.BusinessPlannerActivity.onCreate(BusinessPlannerActivity.java:64) at
Please check it yourself, or post it here.
I removed Gen folder and then again clean and build project and the error has gone.
Same, error went away after a clean project and do a rebuild.
I'm using 'adb -d logcat' in terminal to view my applications log files. Recently, I've been hitting a large block of Runtime Errors- all of which I cannot see for some reason. It just stops at the end with '...30 more' :
[ 08-11 12:27:45.500 8801:0x2261 E/AndroidRuntime ]
FATAL EXCEPTION: main
java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:347)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
at android.widget.AbsListView.obtainView(AbsListView.java:1430)
at android.widget.ListView.makeAndAddView(ListView.java:1745)
at android.widget.ListView.fillDown(ListView.java:670)
at android.widget.ListView.fillFromTop(ListView.java:727)
at android.widget.ListView.layoutChildren(ListView.java:1598)
at android.widget.AbsListView.onLayout(AbsListView.java:1260)
at android.view.View.layout(View.java:7175)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7175)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7175)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7175)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7175)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7175)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.FrameLayout
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:340)
... 30 more
How can I view the '... 30 more' problems that I'm receiving in the logcat??
From the question Print full call stack on printStackTrace()? :
here is an explanation of the 'caused by' and '... n more'
lines in the printed trace. see also the JavaDoc for
printStackTrace. you might not have any work to do.
Note the presence of lines containing the characters "...". These
lines indicate that the remainder of the stack trace for this
exception matches the indicated number of frames from the bottom of
the stack trace of the exception that was caused by this exception
(the "enclosing" exception). This shorthand can greatly reduce the
length of the output in the common case where a wrapped exception is
thrown from same method as the "causative exception" is caught.
I am trying to inflate a layout containing a Fragment using the backwards compatibility package. I took the jar file and placed it in the libs folder of my project. I extended Fragment and then tried to inflate it by setting the contentView of the Activity to
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<fragment
class="com.test.fragments.AdFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/></LinearLayout>
But when I set the content view it fails with a ClassNotFoundException for the fragment tag.
Here is the logcat output.
java.lang.RuntimeException: Unable to start activity ComponentInfo{}: \
android.view.InflateException: Binary XML file line #51: \
Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1793)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3848)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
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: android.view.InflateException: Binary XML file line #51: \
Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:211)
at android.app.Activity.setContentView(Activity.java:1657)
at com.test.base.activities.TabbedStoreActivity.onCreate(TabbedStoreActivity.java:46)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1731)
... 11 more
Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader \
dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar: \
/data/app/com.test.test.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.view.LayoutInflater.createView(LayoutInflater.java:471)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
... 20 more
Make sure your activity is inheriting from FragmentActivity, otherwise <fragment> does not work. Here is a sample project demonstrating this.