Android Question [Solved] Crash in B4A 10.7, xml.LoadCmlLayout

mw71

Active Member
Licensed User
Longtime User
hi,

download B4A 10.7, Compile with no change of (relevante) Code.
Compile, Install, Crash

the Crash is in this, line 2:
B4X:
    Dim xml As XmlLayoutBuilder
    xml.LoadXmlLayout(Panel_chk_gps, "checkbox")
    chk_always_on= xml.GetView("chk1")

i have add this (very) long time bevore to have a Checkbox with special Text Aligment.
It Works in previous Versions fine.

- the XML File ist locate in Objects/res/layout (i hope thats rigth)
- inside:
XML:
<?xml version="1.0" encoding="utf-8"?>
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/chk1"

  android:layout_width="85dip"
  android:layout_height="55dip"
  android:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"

  android:tag="chk1" />


main$ResumableSub_Activity_Createresume (java line: 1981)
android.content.res.Resources$NotFoundException: File res/layout/checkbox from xml type layout resource ID #0x7f080000
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1254)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2283)
at android.content.res.Resources.getLayout(Resources.java:1175)
at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at anywheresoftware.b4a.object.XmlLayoutBuilder.LoadXmlLayout(XmlLayoutBuilder.java:49)
at de.udxsoft.udxlog.main$ResumableSub_Activity_Create.resume(main.java:1981)
at de.udxsoft.udxlog.main._activity_create(main.java:1425)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at de.udxsoft.udxlog.main.afterFirstLayout(main.java:105)
at de.udxsoft.udxlog.main.access$000(main.java:17)
at de.udxsoft.udxlog.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7582)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.nativeOpenXmlAsset(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:1041)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1238)
... 19 more
android.content.res.Resources$NotFoundException: File res/layout/checkbox from xml type layout resource ID #0x7f080000
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1254)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2283)
at android.content.res.Resources.getLayout(Resources.java:1175)
at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at anywheresoftware.b4a.object.XmlLayoutBuilder.LoadXmlLayout(XmlLayoutBuilder.java:49)
at de.udxsoft.udxlog.main$ResumableSub_Activity_Create.resume(main.java:1981)
at de.udxsoft.udxlog.main._activity_create(main.java:1425)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at de.udxsoft.udxlog.main.afterFirstLayout(main.java:105)
at de.udxsoft.udxlog.main.access$000(main.java:17)
at de.udxsoft.udxlog.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7582)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.nativeOpenXmlAsset(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:1041)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1238)
... 19 more
android.content.res.Resources$NotFoundException: File res/layout/checkbox from xml type layout resource ID #0x7f080000
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1254)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2283)
at android.content.res.Resources.getLayout(Resources.java:1175)
at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at anywheresoftware.b4a.object.XmlLayoutBuilder.LoadXmlLayout(XmlLayoutBuilder.java:49)
at de.udxsoft.udxlog.main$ResumableSub_Activity_Create.resume(main.java:1981)
at de.udxsoft.udxlog.main._activity_create(main.java:1425)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at de.udxsoft.udxlog.main.afterFirstLayout(main.java:105)
at de.udxsoft.udxlog.main.access$000(main.java:17)
at de.udxsoft.udxlog.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7582)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.nativeOpenXmlAsset(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:1041)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1238)
... 19 more
 
Last edited:

mw71

Active Member
Licensed User
Longtime User
Attach a Test Project.

The Text is at the left side from the Checkbox.
 

Attachments

  • Test_Chk_Spezi.zip
    9.6 KB · Views: 138
Upvote 0

MikeSW17

Active Member
Licensed User
Longtime User
FWIW, the Example project for XMLLayoutBuilder provided at: https://www.b4x.com/android/forum/threads/xmllayoutbuilder-load-xml-layouts.33762/
Crashes in an Identical manner as your Test Project, so the fault doesn't seem to be just yours.

B4X:
Logger connected to:  samsung SM-G988B
--------- beginning of main
--------- beginning of system
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 34 (Main)
android.content.res.Resources$NotFoundException: File res/layout/checkbox from xml type layout resource ID #0x7f020000
    at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1477)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2540)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2516)
    at android.content.res.Resources.getLayout(Resources.java:1357)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:530)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
    at anywheresoftware.b4a.object.XmlLayoutBuilder.LoadXmlLayout(XmlLayoutBuilder.java:49)
    at b4a.example.main._activity_create(main.java:400)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.main.afterFirstLayout(main.java:105)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:246)
    at android.app.ActivityThread.main(ActivityThread.java:8506)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
    at android.content.res.AssetManager.nativeOpenXmlAsset(Native Method)
    at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:1175)
    at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1461)
    ... 23 more
** Activity (main) Resume **
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
FWIW, the Example project for XMLLayoutBuilder provided at: https://www.b4x.com/android/forum/threads/xmllayoutbuilder-load-xml-layouts.33762/
Crashes in an Identical manner as your Test Project, so the fault doesn't seem to be just yours.
I didn't get any error with that example. Start a new thread for further discussion.


About the OP error:
1. Delete the read-only file. This is the wrong way to create resources.
2. The error happens because android resource files are expected to have an xml extension.
3. Add to manifest editor:
B4X:
CreateResource(layout, checkbox.xml,
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/chk1"

  android:layout_width="85dip"
  android:layout_height="55dip"
  android:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"

  android:tag="chk1" />)
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
Hi Erel,

i have Check, in original (project) it's in the manifest and in the recources
delete rec file, test, crash

With the TestProject (Post #2), Compile with B4A10.7, crash, with B4A 10.5 (other PC) work
-> delete Recource File and add to Manifest
Test, crashs -> look agan, forgot ".xml" in the manifest?‍♂️, now TestProject work.

Correct (add .xml) in the org. Project, work ?

i have Copy/Paste this solution a long time ago. Until B4A 10.6 it works, with 10.7 not, thats was the problem for me.
 
Last edited:
Upvote 0
Top