Android Question B4A on linux (PCLINUXOS MATE) cannot install application with B4A bridge nor with USB cable.

dinge

Member
Licensed User
Longtime User
Hello,
installed B4A on linux according the forum example-instructions (for linux mint 64bit ) on pclinuxos mate 64bit.
B4A runs fine , all seems to work correctly with Wine .
B4A bridge installed on Ulefone Note 8 android works and is connected with B4A over wifi.
B4A status gives notification: Ulefone(Note8 ) connected.
(similar to B4A running on Windows 8 on same laptop where installation & debug works fine)
Compilation runs fine but get ADB error at the end in "Compile & Rapid Debug(Build: default)" window :
(last tree lines)
Signing package file (debug key). (1.87s)
Installing file to device. Error
adb.exe F 12-01 11:41:27 239 240 sysdeps_win32.cpp:2743] _wenviron is not set, did you link with -municode?

Tried also to compile and install with no wifi connection and usb cable connected on phone but gives same error.
I can read and connect to phone in pclinuxos file manager accordingly the settings for usb on phone.
I set USB to thethering (tried also file transfer ) before connecting and trying to install b4a application.

Both give the error :
adb.exe F 12-01 11:41:27 239 240 sysdeps_win32.cpp:2743] _wenviron is not set, did you link with -municode?

I have looked in the forum but do not get a good grip on that problem, had some issues the first time I installed B4A but resolved all these except this error.

What did I do wrong, overlooked or have to change in B4A settings?
 

dinge

Member
Licensed User
Longtime User
Dear Mr Walt61,
thanks for your swift answer.
I did check it again and get in linux terminal adb --version : Android Debug Bridge version 1.0.40
In the Wine Command Prompt window I get in the dir D:\B4X\platform-tools\adb.exe --version : Android Debug Bridge version 1.0.40
(D: = /home/MY_USERNAME ) for Wine
This seems to be a correct install as is mentioned in the example-tutorial

When I run adb.exe in this Wine Command Prompt and ask for adb.exe devices
it gives :
List of devices attached
* daemon not running; starting now at tcp:5307
* daemon started succesfully

second time after that
adb.exe devices gives:
List of devices attached
(empty)

On the other hand in the linux filemanger I get the connection the moment i switch the usb settings on phone to filetransfer .
It shows the phone name and all files (internal and SD-Card) can be viewed in the file manager.

When I try to install the application, with B4A bridge or USB cable, I still get in the "Compile & Debug Rapid(Build:default)" window the error:
adb.exe F 12-01 11:41:27 239 240 sysdeps_win32.cpp:2743] _wenviron is not set, did you link with -municode?

What is the relation between B4A and ADB and the _wenviron?
How to correct this with B4A or other way?
What does link with -municode means for ADB or B4A?

Thanks for your suggestions.
 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
Hi @dinge ,

I'm afraid I have no idea (complete Linux n00b here and I haven't even had time to continue playing with it so far). I just remembered the -municode thing and found on the forum that it was related to the adb version.

That said, there is 1 possible difference with your installation and mine (again, no clue if that could be the cause): I used the Cinnamon desktop, and you appear to be using Mate?

Perhaps others can weigh in here, I know there are people in the community who use B4X on Linux on a daily basis.

Good luck!
 
Upvote 0

dinge

Member
Licensed User
Longtime User
Dear Mr Walt61,
thanks for you reply . Possible. PCLINUXOS sticks to SystemV and ManDrake foundation.
Researched the error:
adb.exe F 12-01 11:41:27 239 240 sysdeps_win32.cpp:2743] _wenviron is not set, did you link with -municode?

sysdeps_win32.cpp seems to have to do with UTF16 to UTF8 conversion and back.
Here some code from this sysdeps_win32.cpp , marked the places where mentioned with '====>'
C++:
extern "C" int main(int argc, char** argv);
 
=====>     // Link with -municode to cause this wmain() to be used as the program
        // entrypoint. It will convert the args from UTF-16 to UTF-8 and call the
        // regular main() with UTF-8 args.
extern "C" int wmain(int argc, wchar_t **argv) {
        // Convert args from UTF-16 to UTF-8 and pass that to main().
        NarrowArgs narrow_args(argc, argv);
        return main(argc, narrow_args.data());
}
 
        // Shadow UTF-8 environment variable name/value pairs that are created from
        // _wenviron the first time that adb_getenv() is called. Note that this is not
        // currently updated if putenv, setenv, unsetenv are called. Note that no
        // thread synchronization is done, but we're called early enough in
        // single-threaded startup that things work ok.
        static auto& g_environ_utf8 = *new std::unordered_map<std::string, char*>();
        // Make sure that shadow UTF-8 environment variables are setup.
    static void _ensure_env_setup() {
        // If some name/value pairs exist, then we've already done the setup below.
        if (g_environ_utf8.size() != 0) {
            return;
    }
 
    if (_wenviron == nullptr) {
        // If _wenviron is null, then -municode probably wasn't used. That
        // linker flag will cause the entry point to setup _wenviron. It will
        // also require an implementation of wmain() (which we provide above).
====>   fatal("_wenviron is not set, did you link with -municode?");
    }

Is there a file missing ( _municode trigger ?) to run properly in 64bit linux laptop and the wine configuration that has to do with the UTF-16 <-> UTF-8 thing ?

Strangely I renamed the adb.exe in the dir platform-tools from adb.exe to _adb.exe and when trying to compile install in B4A (connected with wifi - gives connected status on phone and B4A) to phone still gives the error as before. How is that possible, it should now give a missing file error, don't you think !

I've read in the forum that B4a-bridge does not use adb (??) why then this call to adb and error?

Is there a way to invoke from B4A (setting ) for B4A bridge to compile and debug and be sure it is not calling adb.exe, thus avoiding this error ?

Thanks for any suggestions.
dinge
 
Upvote 0

johnaaronrose

Active Member
Licensed User
Longtime User
Dear Mr Walt61,
thanks for you reply . Possible. PCLINUXOS sticks to SystemV and ManDrake foundation.
Researched the error:
adb.exe F 12-01 11:41:27 239 240 sysdeps_win32.cpp:2743] _wenviron is not set, did you link with -municode?

sysdeps_win32.cpp seems to have to do with UTF16 to UTF8 conversion and back.
Here some code from this sysdeps_win32.cpp , marked the places where mentioned with '====>'
C++:
extern "C" int main(int argc, char** argv);
 
=====>     // Link with -municode to cause this wmain() to be used as the program
        // entrypoint. It will convert the args from UTF-16 to UTF-8 and call the
        // regular main() with UTF-8 args.
extern "C" int wmain(int argc, wchar_t **argv) {
        // Convert args from UTF-16 to UTF-8 and pass that to main().
        NarrowArgs narrow_args(argc, argv);
        return main(argc, narrow_args.data());
}
 
        // Shadow UTF-8 environment variable name/value pairs that are created from
        // _wenviron the first time that adb_getenv() is called. Note that this is not
        // currently updated if putenv, setenv, unsetenv are called. Note that no
        // thread synchronization is done, but we're called early enough in
        // single-threaded startup that things work ok.
        static auto& g_environ_utf8 = *new std::unordered_map<std::string, char*>();
        // Make sure that shadow UTF-8 environment variables are setup.
    static void _ensure_env_setup() {
        // If some name/value pairs exist, then we've already done the setup below.
        if (g_environ_utf8.size() != 0) {
            return;
    }
 
    if (_wenviron == nullptr) {
        // If _wenviron is null, then -municode probably wasn't used. That
        // linker flag will cause the entry point to setup _wenviron. It will
        // also require an implementation of wmain() (which we provide above).
====>   fatal("_wenviron is not set, did you link with -municode?");
    }

Is there a file missing ( _municode trigger ?) to run properly in 64bit linux laptop and the wine configuration that has to do with the UTF-16 <-> UTF-8 thing ?

Strangely I renamed the adb.exe in the dir platform-tools from adb.exe to _adb.exe and when trying to compile install in B4A (connected with wifi - gives connected status on phone and B4A) to phone still gives the error as before. How is that possible, it should now give a missing file error, don't you think !

I've read in the forum that B4a-bridge does not use adb (??) why then this call to adb and error?

Is there a way to invoke from B4A (setting ) for B4A bridge to compile and debug and be sure it is not calling adb.exe, thus avoiding this error ?

Thanks for any suggestions.
dinge
Hi dinge. Did you solve this problem?
 
Upvote 0

dinge

Member
Licensed User
Longtime User
Dear Mr Johnaaronrose,
sadly i did not yet solve the problem. I installed the B4J on same laptop and OS with the idea that perhaps some files would be added that could solve the problem but helas the B4A is now even more corrupted as the logo starts and then disappears. (?) Did not investigate further as i continued to work on my little program in Windows 8 and wanted to finish it for my Onyx Boox Note Air 2. That Worked out fine.
The B4J starts up logo , IDE all ok. When compiling I get an error of a missing file on c:/windows32/Robocopy..exe (by memory) or similar.
I will in the future work this out hoping it solves the problem also with B4A ( perhaps a reinstall off B4A in Wine ).
I will report this here on the forum when I have worked on it. For the moment I am focused on other things.
Thanks for asking and hopefully I can solve and give a how to handle such an install.
Greetings
dinge
 
Upvote 0

johnaaronrose

Active Member
Licensed User
Longtime User
Dear Mr Johnaaronrose,
sadly i did not yet solve the problem. I installed the B4J on same laptop and OS with the idea that perhaps some files would be added that could solve the problem but helas the B4A is now even more corrupted as the logo starts and then disappears. (?) Did not investigate further as i continued to work on my little program in Windows 8 and wanted to finish it for my Onyx Boox Note Air 2. That Worked out fine.
The B4J starts up logo , IDE all ok. When compiling I get an error of a missing file on c:/windows32/Robocopy..exe (by memory) or similar.
I will in the future work this out hoping it solves the problem also with B4A ( perhaps a reinstall off B4A in Wine ).
I will report this here on the forum when I have worked on it. For the moment I am focused on other things.
Thanks for asking and hopefully I can solve and give a how to handle such an install.
Greetings
dinge
Enrique, the problem re "missing file on c:/windows32/Robocopy..exe" is due to a line being in Main (or it might be in B4XPages module) which needs to be deleted. I've found a not-very-good workaround, at least for my phone & tablet which are both API 9 & SDK 28: copy (using copy & paste in Nautilus) the apk file (in the projects' B4A/Objects directory to tnternal Shared Storage, after clicking on the large icon of the phone in Ubuntu's dock to display it. File Manager app in the phone shows the copied apk file. Select it & click on More (at the bottom right) and select 'Open Another App'. Selecting Package Installer then permits installing the app: if asked 'Allow Installs from Untrustworthy Sources'. The disadvantage is that there's no way of connecting to the Log on B4A: you can use LogCat app on the phone but it won't show the line number of code causing an error.
 
Last edited:
Upvote 0

johnaaronrose

Active Member
Licensed User
Longtime User
I've got nearer to the strange message shown in my post #1. Linux adb shows as 28.02 but Windows is 1.0.32 for the file frrom Dropbox shown in step 19 of walt61's Linux installation instructions. This file came from adb unzipped from the downloaded adb 1.0.40.zip at https://www.dropbox.com/sh/a45a6ym8l1ue5fk/AAB-7ocL5O4kSvT7cChZB5LEa?dl=0 . The Linux adb version is correctly 28.0.2 but the Windows adb version is incorrectly 1.0.32 when I run 'adb version' in a VirtualBox Windows 10 VM. Also, the Windows adb does NOT list my phone with 'adb devices' whereas the Linux does list my phone with 'adb devices'. All the files in the platform-tools directory are dated 12 February 2019. Could you update the file in Dropbox to contain the the Windows version 1.0.40 and send me the new link?
 
Upvote 0
Top