Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on API 16 #50

Closed
DreierF opened this issue May 16, 2016 · 9 comments
Closed

Crash on API 16 #50

DreierF opened this issue May 16, 2016 · 9 comments

Comments

@DreierF
Copy link

DreierF commented May 16, 2016

Hi,

first of all thanks for this awesome library!
Unfortunately I'm experiencing a crash when using the library on API level 16. On API 21 everything works fine.

Here is the relevant code for creating the about page

new AboutPage(getContext())
                .setImage(R.drawable.logo)
                .addItem(new Element(null, getString(R.string.share_with_friends), R.drawable.about_icon_share))
                .create();

I'm using the android gradle plugin 2.1.0. about_icon_share is a vector drawable. The library seems to assume that I'm using vectorDrawables.useSupportLibrary = true, which is not the case.

FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.dreier.mytargets/de.dreier.mytargets.activities.SimpleFragmentActivity$AboutActivity}: android.content.res.Resources$NotFoundException: File res/drawable-xhdpi-v4/about_icon_share.png from xml type xml resource ID #0x7f020057
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xhdpi-v4/about_icon_share.png from xml type xml resource ID #0x7f020057
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2145)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2100)
at android.content.res.Resources.getXml(Resources.java:901)
at android.support.graphics.drawable.VectorDrawableCompat.create(VectorDrawableCompat.java:408)
at mehdi.sakout.aboutpage.AboutPage.createItem(AboutPage.java:364)
at mehdi.sakout.aboutpage.AboutPage.addItem(AboutPage.java:241)
at de.dreier.mytargets.fragments.AboutFragment.onCreateView(AboutFragment.java:91)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:601)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5018)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
at android.app.ActivityThread.access$600(ActivityThread.java:130) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4745) 
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:786) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:487)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2127)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2100) 
at android.content.res.Resources.getXml(Resources.java:901) 
at android.support.graphics.drawable.VectorDrawableCompat.create(VectorDrawableCompat.java:408) 
at mehdi.sakout.aboutpage.AboutPage.createItem(AboutPage.java:364) 
at mehdi.sakout.aboutpage.AboutPage.addItem(AboutPage.java:241) 
at de.dreier.mytargets.fragments.AboutFragment.onCreateView(AboutFragment.java:91) 
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) 
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) 
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339) 
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:601) 
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163) 
at android.app.Activity.performStart(Activity.java:5018) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
at android.app.ActivityThread.access$600(ActivityThread.java:130) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4745) 
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:786) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
at dalvik.system.NativeStart.main(Native Method)

You can find the code at https://github.com/dreierf/mytargets

Thanks in advance

@medyo
Copy link
Owner

medyo commented May 16, 2016

Hi @DreierF, I just tried the library samples on API 16, everything works fine.
Try to comment the whole android-about-page code from your fragment and check if it's really the cause.

@DreierF
Copy link
Author

DreierF commented May 16, 2016

Hi @medyo, thanks for your quick reply. If I remove the addItem line everything works fine. If I add it the crash happens :-/

@medyo
Copy link
Owner

medyo commented May 16, 2016

try to add addItem without setting an icon, if it doesn't crash, that means two things, whether the drawable is corrupted, or a compatibily issue at :
https://github.com/medyo/android-about-page/blob/master/library/src/main/java/mehdi/sakout/aboutpage/AboutPage.java#L359

@DreierF
Copy link
Author

DreierF commented May 16, 2016

When icon is set to null it works.

@DreierF
Copy link
Author

DreierF commented May 17, 2016

I just tested compiling with vectorDrawables.useSupportLibrary = true then it works on jelly bean (API 16).

android.content.res.Resources$NotFoundException: File res/drawable-xhdpi-v4/about_icon_share.png from xml type xml resource ID #0x7f020057

This also indicates that VectorDrawableCompat.create expects the resource to be a vector drawable instead of a png.

@DreierF
Copy link
Author

DreierF commented May 20, 2016

I have now "solved" it by enabling vectorDrawables.useSupportLibrary = true for the whole project.
So if nobody else needs this to run with pngs you can close the issue, but I'd suggest to add a hint on this to the readme.

@juandiegoapps
Copy link

Hi. I'm trying to implement it into my app, but How do I have to do it? I'm trying different ways, but it is crashing!

@medyo
Copy link
Owner

medyo commented Jun 23, 2016

@juandiegoapps please open a new issue for your case

@sourabh48
Copy link

i want to use it in fragment is it possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants