Android Question DSFloatingActionButton Resource Error

Anser

Well-Known Member
Licensed User
Hi,

I am really confused and can't figure out where I am going wrong.

I am trying to use DSFloatingActionButton in my app. My app is already using DSNavigationDrawer and is working fine. That means all the required setups to run DesignSupport components is done properly.

The sample application provided by Corwin ie FloatingActionButton1_0.zip is also working fine and I am able to compile and install on my device.

In one of my activities, if I place a DSFloatingActionButton, then I get the run time error at Activity.LoadLayout itself. The error looks like a resource not found error, but I can't understand what resource is missing. If I remove the DSFab from the Layout then everything works fine.

In the sample provided by Corwin oe FloatingActionButton1_0.zip, I could see a resource folder in his project folder. I understand that the resource is used to display a heart sign inside the DSFab. In my case I am not using any resource on the DSFab. Anyways, I tried copying this folder inside my project too, unfortunately, even then I am getting the same error message.

Can anyone guide me where I am going wrong ?.

Please note that this fails at the line Activity.LoadLayout itself. Please note that the layout contains only an AcToolBarLight and the DSFab.

Here is the error message that I get.

** Activity (myactivity) Create, isFirst = true **
myactivity_activity_create (java line: 360)
java.lang.RuntimeException: android.content.res.Resources$NotFoundException: Resource ID #0x0
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at com.mycompany.myappname.myactivity._activity_create(myactivity.java:360)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
at com.mycompany.myappname.myactivity.afterFirstLayout(myactivity.java:102)
at com.mycompany.myappname.myactivity.access$000(myactivity.java:17)
at com.mycompany.myappname.myactivity$WaitForLayout.run(myactivity.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:2558)
at android.content.res.Resources.getDrawable(Resources.java:2001)
at android.content.res.Resources.getDrawable(Resources.java:1987)
at android.content.res.Resources.getDrawable(Resources.java:1961)
at de.amberhome.objects.FloatingActionButtonWrapper.DesignerCreateView(FloatingActionButtonWrapper.java:100)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:70)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
... 14 more
** Service (newinst2) Start **

-- AppUpdating.NewInst2: processing service_start

Here is the code
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
#Extends: android.support.v7.app.AppCompatActivity

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private ActionBar As ACToolBarLight
    Private DSFab As DSFloatingActionButton
End Sub

Sub Activity_Create(FirstTime As Boolean)
       'Fails at this point itself
    Activity.LoadLayout("MyLayoutFile")

    Dim ABHelper As ACActionBar
    ABHelper.Initialize
    ABHelper.ShowUpIndicator = True
    ActionBar.InitMenuListener
    ActionBar.SubTitle = Starter.CompanyName
   
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Here is the Layout

DSFab1.png


Regards

Anser
 

Anser

Well-Known Member
Licensed User
You did not added the line
B4X:
#AdditionalRes: ..\resource
to your code? Note that the Icon for the FAB is inside the resource-Folder. This missing drawable is probably the source of your ResouceNotFound
I forgot to mention that I have already included the #AdditionalRes: ..\resource and that it is in the Main. The code that I posted above is the activity that I am using this DSFab.

I am planning to display the DSFab without any icon, so that I can avoid any errors related to the resource amd then later on add an Icon
 
Last edited:
Upvote 0

Anser

Well-Known Member
Licensed User
Reading the Sample provided by Corwin, the library does not require any AdditionalRes.
He has used a #AdditionalRes: ..\resource in the sample project but I understand that this particular resource folder is used to display an ICON inside the DSFab, specific to that sample project and not for the library.

Not to take any chances and to pin point the problem, I copied and included the resource folder from Corwin's sample project to my project. Unfortunately, the same error.
 
Upvote 0

Anser

Well-Known Member
Licensed User
Double check that the library is correct and you didn't add don's library instead.
I once again, unziped and extracted Corwin's DesignSupport Library to my Additional Libs folder, so that I can rule out this doubt. Unfortunately, I get the same error.
 
Upvote 0

corwin42

Expert
Licensed User
It is simply a bug.

The DSFloatingActionButton (if added by designer) tries to load a icon resource even if the resource name (Icon Drawable property) in the designer property is empty.

It will be fixed in the next version.
 
Upvote 0
Top