Android Question Copy layouts cross platform between B4A, B4i and B4J

grant1842

Active Member
Licensed User
Longtime User
I have been reading

I am working on a b4i/b4a app.

I noticed when i design the layout in b4i and then copy the views to b4a i get this error.

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
#SupportedOrientations attribute must be set to landscape or portrait.
*** mainpage: B4XPage_Created
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:38)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:338)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:133)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:314)
at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:60)
at b4a.example.b4xmainpage.callSub(b4xmainpage.java:169)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1098)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1069)
at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:528)
at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:865)
at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:199)
at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:206)
at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:716)
at b4a.example.main._activity_create(main.java:365)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
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:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: keyboard.png
at anywheresoftware.b4a.objects.ImageViewWrapper.setImage(ImageViewWrapper.java:103)
at anywheresoftware.b4a.objects.ImageViewWrapper.build(ImageViewWrapper.java:124)
... 31 more
Caused by: java.io.FileNotFoundException: keyboard.png
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:347)
at android.content.res.AssetManager.open(AssetManager.java:321)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:208)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:516)
at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:69)
at anywheresoftware.b4a.objects.ImageViewWrapper.setImage(ImageViewWrapper.java:101)
... 32 more
b4xmainpage_b4xpage_created (java line: 60)
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).
Did you forget to call Activity.LoadLayout?
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:314)
at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:60)
at b4a.example.b4xmainpage.callSub(b4xmainpage.java:169)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1098)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1069)
at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:528)
at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:865)
at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:199)
at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:206)
at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:716)
at b4a.example.main._activity_create(main.java:365)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
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:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
Caused by: java.lang.RuntimeException: Object should first be initialized (ImageView).
Did you forget to call Activity.LoadLayout?
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:73)
at anywheresoftware.b4a.objects.ImageViewWrapper.innerInitialize(ImageViewWrapper.java:36)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:423)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:133)
... 24 more
If i add all the same views manually it works fine.

Am i not doing something correct ?

Thanks for any help.
 

grant1842

Active Member
Licensed User
Longtime User
I did a quick test app. I started in b4j and b4a.
If i run in debug mode all is good.

I i run in release mode then a crash on bra, and b4j
I am attaching the test project
Thaks for any help
 

Attachments

  • CrossTest.zip
    16.5 KB · Views: 138
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
I did a quick test app. I started in b4j and b4a.
If i run in debug mode all is good.

I i run in release mode then a crash on bra, and b4j
I am attaching the test project
Thaks for any help
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    vpage1.IsInitialized
    B4XPages.AddPage("b4xPage1", vpage1)
    
End Sub

should be


B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    vpage1.Initialize
    B4XPages.AddPage("b4xPage1", vpage1)
    
End Sub
 
Upvote 0

grant1842

Active Member
Licensed User
Longtime User
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
   
    vpage1.IsInitialized
    B4XPages.AddPage("b4xPage1", vpage1)
   
End Sub

should be


B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
   
    vpage1.Initialize
    B4XPages.AddPage("b4xPage1", vpage1)
   
End Sub
Thanks John that was it on the test . Iet me look at my other app that is doing the same thing.
 
Upvote 0

grant1842

Active Member
Licensed User
Longtime User
There is 3 image views that i copied from b4i to b4a.
If i delete the ones i copied and add 3 more manually it works.

And if i copy files from the b4i project again then it does not work and i have to delete the 3 image views and add them again.
Not sure if i am doing something wrong.
Thanks for the help
 
Last edited:
Upvote 0

grant1842

Active Member
Licensed User
Longtime User
I went into the project folder and manually copied the image files over and now i can copy the layout from b4i to bra and it works.
I was adding the files in the designer .
weard........

This forum is great thanks for all the help
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Upvote 0
Top