I have a series of images on drawable folder that I want to reuse in a language folder (drawable-pt) so I created an xml file for each image in the language folder like this:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/habitat_over" />
then I have in a xml folder a xml file that represents button states:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="#drawable/habitat_over"/>
<item android:drawable="#drawable/habitat" />
</selector>
in the layout I have something like this:
<ImageButton android:layout_weight="1"
android:background="#null"
android:layout_width="wrap_content"
android:src="#xml/habitat_button"
android:id="#+id/habitat"
android:layout_height="wrap_content"
android:scaleType="fitCenter">
</ImageButton>
It should work but when I run the application this error shows up:
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
E/AndroidRuntime( 409): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
E/AndroidRuntime( 409): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime( 409): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
E/AndroidRuntime( 409): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
E/AndroidRuntime( 409): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
E/AndroidRuntime( 409): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
E/AndroidRuntime( 409): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
E/AndroidRuntime( 409): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
E/AndroidRuntime( 409): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
E/AndroidRuntime( 409): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
E/AndroidRuntime( 409): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
E/AndroidRuntime( 409): at android.app.Activity.setContentView(Activity.java:1657)
E/AndroidRuntime( 409): at pnm.freiramadeira.ChapterSelection.onCreate(ChapterSelection.java:90)
E/AndroidRuntime( 409): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 409): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
E/AndroidRuntime( 409): ... 11 more
E/AndroidRuntime( 409): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 409): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 409): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
E/AndroidRuntime( 409): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
E/AndroidRuntime( 409): ... 25 more
E/AndroidRuntime( 409): Caused by: android.content.res.Resources$NotFoundException: File res/xml/habitat_button.xml from drawable resource ID #0x7f050007
E/AndroidRuntime( 409): at android.content.res.Resources.loadDrawable(Resources.java:1697)
E/AndroidRuntime( 409): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime( 409): at android.widget.ImageView.<init>(ImageView.java:118)
E/AndroidRuntime( 409): at android.widget.ImageButton.<init>(ImageButton.java:85)
E/AndroidRuntime( 409): at android.widget.ImageButton.<init>(ImageButton.java:81)
E/AndroidRuntime( 409): ... 28 more
E/AndroidRuntime( 409): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-pt/habitat_over.xml from drawable resource ID #0x7f02002f
E/AndroidRuntime( 409): at android.content.res.Resources.loadDrawable(Resources.java:1697)
E/AndroidRuntime( 409): at android.content.res.Resources.getDrawable(Resources.java:581)
E/AndroidRuntime( 409): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
E/AndroidRuntime( 409): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
E/AndroidRuntime( 409): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
E/AndroidRuntime( 409): at android.content.res.Resources.loadDrawable(Resources.java:1694)
E/AndroidRuntime( 409): ... 32 more
E/AndroidRuntime( 409): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: <bitmap> requires a valid src attribute
E/AndroidRuntime( 409): at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:375)
E/AndroidRuntime( 409): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
E/AndroidRuntime( 409): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
E/AndroidRuntime( 409): at android.content.res.Resources.loadDrawable(Resources.java:1694)
E/AndroidRuntime( 409): ... 37 more
Does anyone knows why this happens??
Thanks in advance!!
Even though it's not really documented, the android:src attribute of a <bitmap> only accepts image files (not drawables defined in XML).
Instead of having src="#drawable/habitat_over" in a bitmap and referencing that <bitmap> from your layout, remove the <bitmap> and add a direct reference to from the layout to #drawable/habitat_over.
Related
While testing my latest android game on 2.3.5 the leader boards (using Google play services) kept crashing although I used previously tested code in other games. So I tried out apps from the play store, and noticed that all apps are crashing when opening the leader boards on android devices with 2.3
Is this a bug in google play services? (I am using the API9+ version of PLay services)
Test devices:
HTC ChaCha 2.3.5
Samsung Galaxy GIO 2.3.6
Anyone has an idea? Do have have an android 2.3 device that currently has a game with play services leaderboards successfully opening?
Thank you
EDIT3:
I opened a defect for the issue since the new versions of play services did not fix it:
https://code.google.com/p/play-games-platform/issues/detail?id=194
feel free to star the issue
PS: you might not get crash reports in your developer console because the game continues to run it is the services/leaderboards activity that crashes
EDIT2:
Issue still present on 6.1.83 !
EDIT1:
Adding the stack below, it seems that there is a resource missing which is in the GUI of the leaderboard, and as far as I know, the developer cannot fix it in his app because the play services project will be used is the one fetched from the play services version running on the user's device right?
Stack
E/AndroidRuntime( 1928): android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.Ch
eckBox
E/AndroidRuntime( 1928): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
E/AndroidRuntime( 1928): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater
.java:56)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
E/AndroidRuntime( 1928): at com.google.android.gms.games.ui.common.leaderboards.o.a(SourceFile:113)
E/AndroidRuntime( 1928): at com.google.android.gms.games.ui.cg.a(SourceFile:14)
E/AndroidRuntime( 1928): at com.google.android.gms.games.ui.bo.a(SourceFile:18)
E/AndroidRuntime( 1928): at android.support.v7.widget.cf.b(SourceFile:3204)
E/AndroidRuntime( 1928): at android.support.v7.widget.au.a(SourceFile:1789)
E/AndroidRuntime( 1928): at android.support.v7.widget.am.a(SourceFile:268)
E/AndroidRuntime( 1928): at android.support.v7.widget.LinearLayoutManager.a(SourceFile:1251)
E/AndroidRuntime( 1928): at android.support.v7.widget.LinearLayoutManager.a(SourceFile:508)
E/AndroidRuntime( 1928): at android.support.v7.widget.am.a(SourceFile:82)
E/AndroidRuntime( 1928): at android.support.v7.widget.RecyclerView.e(SourceFile:1869)
E/AndroidRuntime( 1928): at android.support.v7.widget.RecyclerView.onLayout(SourceFile:2106)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.support.v4.widget.SwipeRefreshLayout.onLayout(SourceFile:536)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime( 1928): at com.google.android.play.headerlist.PlayHeaderListLayout.onLayout(SourceFile:798)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
E/AndroidRuntime( 1928): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
E/AndroidRuntime( 1928): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(SourceFile:503)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
E/AndroidRuntime( 1928): at android.view.View.layout(View.java:7175)
E/AndroidRuntime( 1928): at android.view.ViewRoot.performTraversals(ViewRoot.java:1146)
E/AndroidRuntime( 1928): at android.view.ViewRoot.handleMessage(ViewRoot.java:1866)
E/AndroidRuntime( 1928): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1928): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 1928): at android.app.ActivityThread.main(ActivityThread.java:3687)
E/AndroidRuntime( 1928): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1928): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 1928): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
E/AndroidRuntime( 1928): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
E/AndroidRuntime( 1928): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1928): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 1928): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 1928): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
E/AndroidRuntime( 1928): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
E/AndroidRuntime( 1928): ... 54 more
E/AndroidRuntime( 1928): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/games_white_check
box.xml from drawable resource ID #0x7f020165
E/AndroidRuntime( 1928): at android.content.res.Resources.loadDrawable(Resources.java:1697)
E/AndroidRuntime( 1928): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime( 1928): at android.widget.CompoundButton.<init>(Compo
I have the same thing started recently (Android 2.3.6).
I think there is only Google can fix (
I'm trying to port the Contacts APK from the galaxy S5 to the Galaxy S4.
I got a FC when I tried to launch the application. I would like to get some help fixing this issue.
E/AndroidRuntime( 3085): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.contacts/com.android.contacts.activities.PeopleActivity}: android.view.InflateException: Binary XML file line #71: Error inflating class <unknown>
E/AndroidRuntime( 3085): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
E/AndroidRuntime( 3085): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
E/AndroidRuntime( 3085): at android.app.ActivityThread.access$900(ActivityThread.java:161)
E/AndroidRuntime( 3085): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
E/AndroidRuntime( 3085): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 3085): at android.os.Looper.loop(Looper.java:157)
E/AndroidRuntime( 3085): at android.app.ActivityThread.main(ActivityThread.java:5356)
E/AndroidRuntime( 3085): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3085): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 3085): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
E/AndroidRuntime( 3085): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
E/AndroidRuntime( 3085): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
E/AndroidRuntime( 3085): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3085): Caused by: android.view.InflateException: Binary XML file line #71: Error inflating class <unknown>
E/AndroidRuntime( 3085): at android.view.LayoutInflater.createView(LayoutInflater.java:626)
E/AndroidRuntime( 3085): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime( 3085): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
E/AndroidRuntime( 3085): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
E/AndroidRuntime( 3085): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
E/AndroidRuntime( 3085): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
E/AndroidRuntime( 3085): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
E/AndroidRuntime( 3085): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:627)
E/AndroidRuntime( 3085): at android.view.LayoutInflater.inflate(Native Method)
E/AndroidRuntime( 3085): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
E/AndroidRuntime( 3085): at com.android.dialer.dialpad.DialpadFragment.onCreateView(DialpadFragment.java:672)
E/AndroidRuntime( 3085): at android.app.Fragment.performCreateView(Fragment.java:1700)
E/AndroidRuntime( 3085): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
E/AndroidRuntime( 3085): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
E/AndroidRuntime( 3085): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1044)
E/AndroidRuntime( 3085): at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1853)
E/AndroidRuntime( 3085): at android.app.Activity.performCreate(Activity.java:5429)
E/AndroidRuntime( 3085): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime( 3085): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
E/AndroidRuntime( 3085): ... 12 more
E/AndroidRuntime( 3085): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 3085): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 3085): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
E/AndroidRuntime( 3085): at android.view.LayoutInflater.createView(LayoutInflater.java:600)
E/AndroidRuntime( 3085): ... 30 more
E/AndroidRuntime( 3085): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/dialpad_background.xml from drawable resource ID #0x7f0200e2
E/AndroidRuntime( 3085): at android.content.res.Resources.loadDrawable(Resources.java:3010)
E/AndroidRuntime( 3085): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
E/AndroidRuntime( 3085): at android.content.res.XResources$XTypedArray.getDrawable(XResources.java:797)
E/AndroidRuntime( 3085): at android.view.View.<init>(View.java:3694)
E/AndroidRuntime( 3085): at android.view.View.<init>(View.java:3624)
E/AndroidRuntime( 3085): ... 33 more
E/AndroidRuntime( 3085): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: <bitmap> requires a valid src attribute
E/AndroidRuntime( 3085): at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:577)
E/AndroidRuntime( 3085): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:973)
E/AndroidRuntime( 3085): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:913)
E/AndroidRuntime( 3085): at android.content.res.Resources.loadDrawable(Resources.java:3006)
E/AndroidRuntime( 3085): ... 37 more
W/ActivityManager( 1126): Force finishing activity com.android.contacts/.activities.PeopleActivity
Here is the zip containing the files from the app from apktool.
SecContacts
I am trying to build an app in AOSP, my development kit has HDPI density, I have double verified it with the following code snippet:
switch (getResources().getDisplayMetrics().densityDpi) {
case DisplayMetrics.DENSITY_LOW:
Log.d(TAG, "\n\n\n\n LDPI \n\n\n\n");
break;
case DisplayMetrics.DENSITY_MEDIUM:
Log.d(TAG, "\n\n\n\n MDPI \n\n\n\n");
break;
case DisplayMetrics.DENSITY_HIGH:
Log.d(TAG, "\n\n\n\n HDPI \n\n\n\n");
// ...
break;
case DisplayMetrics.DENSITY_XHIGH:
Log.d(TAG, "\n\n\n\n XDPI \n\n\n\n");
// ...
break;
}
when I build my application in Android File system,and if I run it, then I am getting following error:
E/AndroidRuntime( 825): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.Button
E/AndroidRuntime( 825): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 825): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 825): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 825): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 825): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 825): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 825): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 825): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 825): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 825): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 825): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 825): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 825): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.Button
E/AndroidRuntime( 825): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
E/AndroidRuntime( 825): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime( 825): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
E/AndroidRuntime( 825): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
E/AndroidRuntime( 825): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:823)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:729)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
E/AndroidRuntime( 825): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
E/AndroidRuntime( 825): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime( 825): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime( 825): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
E/AndroidRuntime( 825): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
E/AndroidRuntime( 825): at android.app.Activity.setContentView(Activity.java:1835)
E/AndroidRuntime( 825): at com.example.MainActivity.onCreate(MainActivity.java:96)
E/AndroidRuntime( 825): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 825): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 825): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 825): ... 11 more
E/AndroidRuntime( 825): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 825): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 825): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
E/AndroidRuntime( 825): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
E/AndroidRuntime( 825): ... 29 more
E/AndroidRuntime( 825): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02000d a=-1 r=0x7f02000d}
E/AndroidRuntime( 825): at android.content.res.Resources.loadDrawable(Resources.java:1897)
E/AndroidRuntime( 825): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
E/AndroidRuntime( 825): at android.widget.TextView.<init>(TextView.java:620)
E/AndroidRuntime( 825): at android.widget.Button.<init>(Button.java:108)
E/AndroidRuntime( 825): at android.widget.Button.<init>(Button.java:104)
E/AndroidRuntime( 825): ... 32 more
My all the drawable resources are in drawable-hdpi.
But if I put drawables in all the drawable-* folder then app runs.
But then UI is getting scattered.
Does anybody have idea, what the problem could. Do I have to add any Variable or flag in the Android.mk
=========edit=========
The app works fine if I build with eclipse. And run on the same device.
Therefore issue might be in building app along with AOSP.
========================
Any help would be highly appreciated.
Regards,
Yuvi
So after struggling too long and googling for more then two days, I found the issue. There was no drawable-hdpi folder in apk. I have resolved the issue by adding the LOCAL_AAPT_FLAGS += -c mdpi,hdpi,xhdpi line in Android.mk file.
Those who are struggling with the same kind of problem follow these supper steps:
Check at which line it is giving error:
Binary XML file line #11: Error inflating class android.widget.Button
In my xml file it was:
<Button
android:id="#+id/btn_footer_back"
style="#style/normalButtonStyle"
android:layout_width="wrap_content"
android:layout_height="60px"
android:layout_marginRight="1dp"
android:background="#drawable/button_state_selector"
android:drawableLeft="#drawable/ic_back"
android:drawablePadding="10px"
android:text="#string/back"
android:visibility="gone" />
So, what is the next step now, the log itself tells the story, check the line:
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02000d a=-1 r=0x7f02000d}
Here r=0x7f02000d is the resource id, that you can find in yourproject/gen/R.java
if you search for 0x7f02000d in R.java then you will able to find which resource is creating the problem, in my case it was R.drawable.ic_back
Hope it helps other to resolve their problems.
Regards,
Yuvi
Your UI is scattered because your files are not matching to appropriate density or resolution while displaying on device. You should use density independent pixels in xml.
And Create Drawable folder and put your files in it. And give reference of the drawable folder.
I recently got some app source code. So I imported to Eclipse and renamed application package. It all went well until I tried launch the app. When I do it instantly crashes. I was wondering why. This is the log:
E/ActivityManager( 215): heap conf. property name string trimmed: hs.com.shadycorp.MoonStoneMarbl
E/AndroidRuntime( 5644): FATAL EXCEPTION: main
E/AndroidRuntime( 5644): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.shadycorp.MoonStoneMarble/theHardestGame.pac.GameLogicController}: java.lang.ClassNotFoundException: theHardestGame.pac.GameLogicController in loader dalvik.system.PathClassLoader[/data/app/com.shadycorp.MoonStoneMarble-1.apk]
E/AndroidRuntime( 5644): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1580)
E/AndroidRuntime( 5644): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674)
E/AndroidRuntime( 5644): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 5644): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:942)
E/AndroidRuntime( 5644): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5644): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 5644): at android.app.ActivityThread.main(ActivityThread.java:3735)
E/AndroidRuntime( 5644): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5644): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 5644): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
E/AndroidRuntime( 5644): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:662)
E/AndroidRuntime( 5644): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5644): Caused by: java.lang.ClassNotFoundException: theHardestGame.pac.GameLogicController in loader dalvik.system.PathClassLoader[/data/app/com.shadycorp.MoonStoneMarble-1.apk]
E/AndroidRuntime( 5644): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
E/AndroidRuntime( 5644): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
E/AndroidRuntime( 5644): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime( 5644): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 5644): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1572)
E/AndroidRuntime( 5644): ... 11 more
E/AndroidRuntime( 5644): [Blue Error Handler] Make Debugging Report file for main
E/AndroidRuntime( 5644): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.shadycorp.MoonStoneMarble/theHardestGame.pac.GameLogicController}: java.lang.ClassNotFoundException: theHardestGame.pac.GameLogicController in loader dalvik.system.PathClassLoader[/data/app/com.shadycorp.MoonStoneMarble-1.apk]
E/AndroidRuntime( 5644): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1580)
E/AndroidRuntime( 5644): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674)
E/AndroidRuntime( 5644): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 5644): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:942)
E/AndroidRuntime( 5644): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5644): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 5644): at android.app.ActivityThread.main(ActivityThread.java:3735)
E/AndroidRuntime( 5644): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5644): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 5644): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
E/AndroidRuntime( 5644): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:662)
E/AndroidRuntime( 5644): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5644): Caused by: java.lang.ClassNotFoundException: theHardestGame.pac.GameLogicController in loader dalvik.system.PathClassLoader[/data/app/com.shadycorp.MoonStoneMarble-1.apk]
E/AndroidRuntime( 5644): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
E/AndroidRuntime( 5644): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
E/AndroidRuntime( 5644): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime( 5644): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 5644): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1572)
this is my android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="theHardestGame.pac"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".GameLogicController"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Check the default action in AndroidManifest.xml. It's probably set to theHardestGame.pac.GameLogicController and should be something else.
Looks like you've not updated the package consistently. In your manifest it's "theHardestGame.pac", while the application package seems to be "com.shadycorp.MoonStoneMarble". I suggest you search for those strings and make sure you've updated everything. Also make sure you're doing a clean build.
I have defined some custom attributes that I want to use throughout my app, which work fine when running through Eclipse, but throws an exception sometimes when the APK has been built and distributed. Below is the stack trace of the exception:
W/dalvikvm( 2521): threadid=1: thread exiting with uncaught exception (group=0x40f44300)
E/AndroidRuntime( 2521): FATAL EXCEPTION: main
E/AndroidRuntime( 2521): android.view.InflateException: Binary XML file line #13: Error inflating class <unknown>
E/AndroidRuntime( 2521): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
E/AndroidRuntime( 2521): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime( 2521): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
E/AndroidRuntime( 2521): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
E/AndroidRuntime( 2521): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
E/AndroidRuntime( 2521): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
E/AndroidRuntime( 2521): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
E/AndroidRuntime( 2521): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime( 2521): at com.myapp.android.ui.fragment.CustomDialogFragmentImpl.onCreateView(CustomDialogFragmentImpl.java:74)
E/AndroidRuntime( 2521): at com.myapp.android.ui.fragment.SupportCustomDialogFragment.onCreateView(SupportCustomDialogFragment.java:41)
E/AndroidRuntime( 2521): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:870)
E/AndroidRuntime( 2521): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
E/AndroidRuntime( 2521): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
E/AndroidRuntime( 2521): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
E/AndroidRuntime( 2521): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
E/AndroidRuntime( 2521): at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime( 2521): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 2521): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 2521): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 2521): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2521): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 2521): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 2521): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 2521): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2521): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 2521): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 2521): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
E/AndroidRuntime( 2521): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
E/AndroidRuntime( 2521): ... 23 more
E/AndroidRuntime( 2521): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
E/AndroidRuntime( 2521): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
E/AndroidRuntime( 2521): at android.view.View.<init>(View.java:3342)
E/AndroidRuntime( 2521): at android.view.ViewGroup.<init>(ViewGroup.java:427)
E/AndroidRuntime( 2521): at android.widget.FrameLayout.<init>(FrameLayout.java:101)
E/AndroidRuntime( 2521): at android.widget.FrameLayout.<init>(FrameLayout.java:97)
E/AndroidRuntime( 2521): ... 26 more
Here is the view at line #13:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="12dp"
android:paddingLeft="?attr/listItemPaddingLeft"
android:paddingRight="?attr/listItemPaddingRight" >
Here is my defined attributes:
<declare-styleable name="MyAppTheme">
<attr name="listItemPaddingLeft" format="dimension" />
<attr name="listItemPaddingRight" format="dimension" />
<attr name="listItemHeight" format="dimension" />
<attr name="listHeaderHeight" format="dimension" />
</declare-styleable>
And lastly, here is my theme:
<style name="MyAppTheme" parent="#style/Theme.Sherlock.Light">
<item name="listItemPaddingLeft">22dp</item>
<item name="listItemPaddingRight">22dp</item>
<item name="listItemHeight">43dp</item>
<item name="listHeaderHeight">73dp</item>
</style>
Does anyone see any problems with the way I've defined things, or can offer an explanation as to why this would work when built locally, but not when the APK is signed? My device is the Galaxy Nexus, which worked fine locally and with the signed APK, but the Galaxy S3 does not work with the signed APK (wasn't able to test it locally).
You need to make sure that the currently (used)set theme is one which contains your custom attribute. You can set it in the manifest file or just set it explicitly before inflating the layout:
setTheme(R.style.MyAppTheme)
setContentView(R.layout.MyActivity);