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

The icon: res://ic_add_white was not found. Check your XML icon property #76

Closed
francisrod01 opened this issue Jun 4, 2018 · 8 comments

Comments

@francisrod01
Copy link

So.. I think the ic_add_white bundle could be created for the plugin.

Project environments

dependencies:

  • node.js: v8.11.2
  • nativescript-angular: ~5.2.0
  • nativescript-floatingactionbutton: ^4.1.3
  • nativescript-theme-core: ~1.0.4
  • reflect-metadata: ~0.1.8
  • rxjs: ~5.5.2
  • tns-core-modules: ^4.1.0

devDependencies:

  • nativescript: ^4.1.0
  • nativescript-dev-typescript: ~0.6.0
  • tslint: ^5.9.1
  • typescript: ~2.6.2
@anki247
Copy link

anki247 commented Jun 30, 2018

Same here...
For me this error msg shows only on Android.

@darkmantle
Copy link

That is only a reference to the icon, you would have to create/download the icon and add it to your AppResources as per instructions here:

https://docs.nativescript.org/ui/images#load-images-from-a-resource

@CoreyCole
Copy link
Contributor

CoreyCole commented Aug 21, 2018

I've added font-awesome icons, trying to use them for the FAB

<Fab 
  (tap)="fabTap()" 
  row="1" 
  [icon]="plusIcon" 
  rippleColor="#f1f1f1" 
  class="fab-button font-awesome">
</Fab>
plusIcon = String.fromCharCode(0xf067);

This is working for me on ios, but on Android, I get the error

An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException: 
Calling js method onCreateView failed

Error: android.content.res.Resources$NotFoundException: Resource ID #0x0
    android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:224)
    android.content.res.Resources.getDrawableForDensity(Resources.java:876)
    android.content.res.Resources.getDrawable(Resources.java:819)
    android.content.res.Resources.getDrawable(Resources.java:794)
    com.tns.Runtime.callJSMethodNative(Native Method)
    com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
    com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
    com.tns.Runtime.callJSMethod(Runtime.java:983)
    com.tns.Runtime.callJSMethod(Runtime.java:967)
    com.tns.Runtime.callJSMethod(Runtime.java:959)
    com.tns.FragmentClass.onCreateView(FragmentClass.java:45)
    android.support.v4.app.Fragment.performCreateView(Fragment.java:2239)
    android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1332)
    android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1574)
    android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1641)
    android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794)
    android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
    android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200)
    android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2153)
    android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2063)
    android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:725)
    android.os.Handler.handleCallback(Handler.java:790)
    android.os.Handler.dispatchMessage(Handler.java:99)
    android.os.Looper.loop(Looper.java:164)
    android.app.ActivityThread.main(ActivityThread.java:6494)
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
File: "file:///data/data/org.nativescript.heymuse/files/app/tns_modules/nativescript-floatingactionbutton/fab.js, line: 81, column: 17

StackTrace: 
	Frame: function:'Fab.(anonymous function)', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/nativescript-floatingactionbutton/fab.js', line: 81, column: 18
	Frame: function:'applyAllNativeSetters', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js', line: 960, column: 28
	Frame: function:'initNativeView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js', line: 904, column: 9
	Frame: function:'ViewBase.onResumeNativeUpdates', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 627, column: 22
	Frame: function:'ViewBase._resumeNativeUpdates', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 272, column: 18
	Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 231, column: 14
	Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 208, column: 35
	Frame: function:'FloatingActionButtonBase.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/nativescript-floatingactionbutton/fab-common.js', line: 14, column: 35
	Frame: function:'', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90
	Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9
	Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14
	Frame: function:'ViewBase.loadView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 439, column: 18
	Frame: function:'', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 233, column: 19
	Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
	Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14
	Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 232, column: 14
	Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 208, column: 35
	Frame: function:'', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90
	Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9
	Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14
	Frame: function:'ViewBase.loadView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 439, column: 18
	Frame: function:'', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 233, column: 19
	Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
	Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14
	Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 232, column: 14
	Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 208, column: 35
	Frame: function:'', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90
	Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9
	Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14
	Frame: function:'ViewBase.loadView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 439, column: 18
	Frame: function:'', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 233, column: 19
	Frame: function:'ContentView.eachChildView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13
	Frame: function:'PageBase.eachChildView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/page/page-common.js', line: 120, column: 40
	Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14
	Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 232, column: 14
	Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 208, column: 35
	Frame: function:'Page.onLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/page/page.js', line: 43, column: 35
	Frame: function:'', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90
	Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9
	Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14
	Frame: function:'ViewBase.loadView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 439, column: 18
	Frame: function:'ViewBase._addViewCore', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 434, column: 18
	Frame: function:'ViewBase._addView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 420, column: 14
	Frame: function:'FragmentCallbacksImplementation.onCreateView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 578, column: 24
	Frame: function:'FragmentClass.onCreateView', file:'file:///data/data/org.nativescript.heymuse/files/app/tns_modules/tns-core-modules/ui/frame/fragment.js', line: 26, column: 38


	at com.tns.Runtime.callJSMethodNative(Native Method)
	at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
	at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
	at com.tns.Runtime.callJSMethod(Runtime.java:983)
	at com.tns.Runtime.callJSMethod(Runtime.java:967)
	at com.tns.Runtime.callJSMethod(Runtime.java:959)
	at com.tns.FragmentClass.onCreateView(FragmentClass.java:45)
	at android.support.v4.app.Fragment.performCreateView(Fragment.java:2239)
	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1332)
	at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1574)
	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1641)
	at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794)
	at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
	at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200)
	at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2153)
	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2063)
	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:725)
	at android.os.Handler.handleCallback(Handler.java:790)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
	at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:224)
	at android.content.res.Resources.getDrawableForDensity(Resources.java:876)
	at android.content.res.Resources.getDrawable(Resources.java:819)
	at android.content.res.Resources.getDrawable(Resources.java:794)
	... 24 more

@bradmartin
Copy link
Collaborator

As noted already, the error comes from the icon not being in the app_resources of the project. I'd rather not bundle the icon since it's just adding extra files to someone's project and they may not use the plus icon for their project. The demo is using this, but perhaps we should change the README and demo to use the default app icon with res://icon so it doesn't throw without the dev changing it on their project 🤔

@CoreyCole - font/text is not supported for the icon. The android native widget extends the Android ImageView widget (going from memory right now so could be a bit off), so adding support for text isn't plug n' play 😄 - if you'd rather use font icons then I'd suggest mocking a FAB with a button and using the NS css to style it height/width and border-radius for a circle 👍

@bradmartin
Copy link
Collaborator

If someone would like to add some notes to the README about that and update the README & demo to use res://icon then I'll be glad to accept any PR about it 👍

@CoreyCole
Copy link
Contributor

Yeah idk the documentation @darkmantle linked is kinda complicated for an mvp if you don't care too much about image sizes. I was able to get it to work by downloading an image to my app/images directory and naming it ic_add_white.png. Then I was able to use it for the fab like this:

<Fab (tap)="fabTap()" row="1" [icon]="'~/images/ic_add_white.png'" class="fab-button"></Fab>

Attaching the image for other people's convenience
ic_add_white

@CoreyCole
Copy link
Contributor

@bradmartin I've opened a PR #79 explaining how to do this simply. Maybe we could also add a line explaining why users might want to pursue the res://icon route and give them the link that @darkmantle provided

@darkmantle
Copy link

I know its closed, but just want to point out that even after commenting the solution myself, I've then forgotten how to fix this error, and found my own solution while Googling

Fail ¬_¬

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

5 participants