Android Question Problems with B4XPages, UltimateWebView and SDK 31 (Android 12)

max123

Well-Known Member
Licensed User
Longtime User
Hi all,

I've tried to convert my app to use B4XPages and SDK 31, but encountered some problems that I don't know how to solve.

In past I had an old 32bit PC with Windows XP (I always compiled with SDK <= 29) and now my new 64bit PC with Windows 11 finally arrived.

Because this is absolutely a first time I use B4XPages and SDK 31, I have some questions and please I need some your advices:

1) Using UltimateWebView when I initialize the UltimateWebViewInterface the app crashes and on the log I see a lot of error messages that I do not know at all, the log message was truncated because is longer than 4000 characters, so it is even difficult to post it here a full log. Because I cannot post log and even my full project I just reproduced it on a small project, the result not changed, when I initialize this way the app crashes (Attached the small Zip Project):
B4X:
JSInterface.Initialize(Me)  ' Crash here, what is wrong ?
It even crashes when I set a WebViewClient this way:
B4X:
UltimateWebView1.WebViewClient = True  ' Crash here, what is wrong ?
.... and even crashes when I add a Javascript interface this way because JSInterface failed to initialize:
B4X:
UltimateWebView1.AddJavascriptInterface(JsInterface,"B4A")
Please, note that with old system compiling with SDK <= 29 (But without B4XPages) all works well.

2) In my original project I've used AHViewPager to slide 10 pages, is this good using B4XPages or B4XPages can replace it by just add new pages ?
I can mantain AHViewPager so I do not need to rewrite a lot of code ? Please, note that any page load it's layout created with Designer.

3) In my original project I use 2 services to work in background, is this needed using B4XPages that already can work in background ?
I need to remove it ? And if yes, how to replace ?

4) Because I will release this app on Google Play Store, in past I created the app folder, with other subfolders on DirRootExternal, and now I managed
Runtime Permissons using rp.GetSafeDirDefaultExternal(AppName), this create the app folder on "sdcard/0/Android/data/packagename/files/appname",
this is not good because if the user uninstall the app, Android will remove all folders, subfolders and files containing important datas. How to avoid it
and create the app folder on "/sdcard/0/appname" folder so when the user uninstall the app the data do not deleted ? I need to use ExternalStorage ?

Many thanks
 

Attachments

  • Project.zip
    15.6 KB · Views: 183
Last edited:

MicroDrie

Well-Known Member
Licensed User
Your program is not configured according to the directions of the UltimateWebView Custom View current version 2.12 rules. For example, the manifest rules are not included and the permissions are not regulated. I'm assuming you updated the SDK correctly and set the correct reference to the additional libraries. Without any display of the error message it will be very difficult to help you.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Many thanks for your reply @MicroDrie.

Unfortunately this is not really true, in my project I've added to the manifest and by code all necessary to support latest UltimateWebView 2.12., @Ivica Golubovic helped me to do it the right way. I worked on it two weeks.

It works well on my old PC with Windows XP and B4A 7.80 on old 32 bit machine (no B4XPages and SDK 29), now I have a new 64 bit Windows 11 machine and I use B4A 11.80 (B4XPages and SDK 31).

I've attached a small project, just ten lines to reproduce the problem, on that zip project I do not edited the manifest but the result is the same as in my app.

Please, can you try the small project I've attached ?

It reproduce the problem, it is not related to permissons, just crashes when Javascript interface is initialized and when I set WebViewClient. Tried it in Release and Debug mode.

Without any display of the error message it will be very difficult to help you
Here an anteprima:
--------- beginning of system
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 25 (B4XMainPage)
java.lang.ClassNotFoundException: llections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=[device=anywheresoftware.b4a.phone.Phone@c785c24, jsinterfacejo=(JavaObject) Not initialized, mcallback=[b4xcollections=null, b4xpages=null, jsinterface=
, main=null, root=(BALayout) anywheresoftware.b4a.BALayout{6dc4236 V.E...... ......I. 0,0-0,0 #2}, starter=null
, ultimatewebview1=, xui=anywheresoftware.b4a.objects.B4XViewWrapper$XUI@f6f8942]
]
, main=null, root=(BALayout) anywheresoftware.b4a.BALayout{6dc4236 V.E...... ......I. 0,0-0,0 #2}, starter=null
, ultimatewe
To view the error log please try the attached project and you can see it yourself.

I think it is related to B4XPages or Android SDK 31. Maybe 'Me' is not the right identifier for Activity module (Root on B4XPages) ?

My B4A enviroment is set right, all other apps works.

Many thanks for your interest.

Max
 
Last edited:
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Any help appreciated please, I work on this project from 2018, 10 and more hours every day, it is a very big project about 150.000 lines of code.

I always helped users when possible and now I'm here that cannot work, from today I cannot work anymore because it do not compile and I don't know because this happen, so I'm to panic.

Please help to know what is the problem with UltimateWebView and reply to other my questions.

Thanks to everyone can help
 
Last edited:
Upvote 0

Ivica Golubovic

Active Member
Licensed User
Ok, the problem is not in the hardware of your computer itself, nor in the version of the operating system. The problem is in the integration of the library in B4XPages. Why do you need to use B4XPages if you already have an activity-based project? Second, why are you using SDK31, the app will work on Android 12 with SDK30.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
if you already have an activity-based project?
Activity based projects are a waste of time. One should switch to B4XPages.

In addition to that i agree not to use targetSDK 31 for now. Time will come when we can use 31. But not yet.
 
Upvote 0

Ivica Golubovic

Active Member
Licensed User
Activity based projects are a waste of time. One should switch to B4XPages.
I totally agree with you about new projects, but not so much when recreating existing projects with over 10000 lines of code, background subroutines and a lot of external libraries. In my opinion it is an unnecessary waste of time and may open up new problems. He stated that the project has 150,000 lines of programming code and that it uses a lot of external libraries, some of them may not have been adapted for B4XPages.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Many thanks @Ivica Golubovic for your reply and help you told me in past and now,

Why do you need to use B4XPages if you already have an activity-based project?
Because my app is really complex, it control 3D printers, CNC machines, laser cutter machines over USB OTG, over socket (local and internet), it even draw in realtime what the machine work, it even show on a webview the IP camera streaming in realtime. The app already works well but cannot do all these in background, using Services for all these is a thing too complex. For this reason use a regular project is pretty difficult and at the end I've opted to port it on B4XPages, in other way it is too difficult to me.

Second, why are you using SDK31, the app will work on Android 12 with SDK30
Because the app already works, but do not work in background, this is the last step I need to do, after this my app apart some small things is pretty finished and finally after 4 years of develop I can release it on Google Play Store.
Google informed that from November 2022 any app must be compiled with API level 31, this is not my decision, see here for more infos:
https://developer.android.com/google/play/requirements/target-sdk#:~:text=Starting in November 2022, app updates must target,newer versions of Android. Why target newer SDKs?

Many thanks for your help
 
Last edited:
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
@DonManfred you are right, I like a lot your comment. πŸ‘ πŸ‘ πŸ‘

But here already is time for API level 31, this is not my decision but Google decision, for me even API 28 or 29 or 30 is not a problem:
https://developer.android.com/google/play/requirements/target-sdk#:~:text=Starting in November 2022, app updates must target,newer versions of Android. Why target newer SDKs?

@Ivica Golubovic , my project do not have 10.000 lines, but near 150.000 lines, yes, it involves not only B4A code (client side), but even Raspberry B4J and Python code, ESP8266 and ESP32 C++ code (server side), is really complex, imagine you can control a 3D printer from anywhere from any Android device even without WiFi, just using a data line (SIM card), control remotely, show on it in realtime video streaming, update the firmware over OTA updates and more....

Only the B4A project is about 50.000 + lines of code.... I've tried to manage it with services but ist too difficult to me, and even as @DonManfred and @Erel said one should switch to B4XPages, using regular project is a wasted of time.

Many thanks
 
Last edited:
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Many Many Many thanks @Ivica Golubovic, you are my Angel πŸ‘ πŸ‘πŸ‘

Meanwhile you see it, just to try, so I can continue to adapt to B4XPages, it should work with B4XPages and API level 30 or just UltimateWebView do not work on top of B4XPages ?

Many thanks
 
Last edited:
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Yes thanks, I will try it just next hours because I'm here that cannot work πŸ‘
Just after Italian Spaghetti🍝🍝 πŸ˜…
 
Last edited:
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
For all users remain open the help request for other questions so I can switch on B4XPages.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Yes, thanks @DonManfred I will do it just exactly now, but because Google only accepts apps compiled with SDK 31 from November I will need to switch to it next days.

I think it is not only my problem, but of any user that need to publish apps on play store.

Other my questions are not related to API Level, but B4XPages, eg. have sense use Services that works in background on top of B4XPages that already do not pause ?

In my app I use 2 services and I need to know it.

Thanks
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
only accepts apps compiled with SDK 31 from November
RIGHT! From NOVEMBER.

IΒ΄m pretty sure B4A will be ready for 31 in November.

For now it is not and the suggested targetSDK is 30. Start with implementing 30 and be patient to get a new B4A Version ready for 31 in the next months.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Ok thanks there is time... I do not need to release it in a short time, not really finished, require some time. I never publish any app, this is a first time so I need to know other things before publish it.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
I search a reply for other questions.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
@Ivica Golubovic I confirm that UltimateWebView works with app compiled on API Level 31 without use B4XPages.

Today I will try it with API Level 30 and B4XPages and post here results.

Thanks
 
Upvote 0
Top