Android Question Error building app bundle (Win11Pro, B4a 11.80)

bigbadfred

Member
Licensed User
Longtime User
I am having a hard time finding a solution for the following error that occurs when trying to build an app bundle:
Module files can be only in pre-defined directories, but found 'libs/android-support-v4.jar
Error building app bundle:
B4A Version: 11.80
Parsing code.    (0.11s)
    Java Version: 8
Building folders structure.    (0.03s)
Compiling code.    (0.08s)
    
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.    (0.03s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Compiling resources    (0.35s)
Linking resources    (1.67s)
Compiling generated Java code.    (1.35s)
Finding libraries that need to be dexed.    (0.01s)
Dex code    (1.83s)
Dex merge    (1.82s)
Copying libraries resources    (3.79s)
Building app bundle    Error
[BT:1.5.0] Error: Module files can be only in pre-defined directories, but found 'libs/android-support-v4.jar'.
com.android.tools.build.bundletool.model.exceptions.InvalidBundleException: Module files can be only in pre-defined directories, but found 'libs/android-support-v4.jar'.
    at com.android.tools.build.bundletool.model.exceptions.UserExceptionBuilder.build(UserExceptionBuilder.java:58)
    at com.android.tools.build.bundletool.validation.BundleFilesValidator.validateModuleFile(BundleFilesValidator.java:156)
    at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModulesUsingSubValidator(ValidatorRunner.java:81)
    at com.android.tools.build.bundletool.validation.ValidatorRunner.lambda$validateBundleModules$4(ValidatorRunner.java:64)
    at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:406)
    at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModules(ValidatorRunner.java:63)
    at com.android.tools.build.bundletool.validation.BundleModulesValidator.validate(BundleModulesValidator.java:82)
    at com.android.tools.build.bundletool.commands.BuildBundleCommand.execute(BuildBundleCommand.java:231)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:71)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:47)

My application compiles fine, I deploy it via Bridge to my phone, no problem.
I am using Windows 11 Pro, B4A 11.80 & sometimes NOX to test different resolutions.

Fixes that I have tried, but that didn't solve the problem:
- TargetSDK=31 (Changed it to 30 & 29, no change)
- Re-installed Java, extracted all the necessary Android archives, to no avail.
- Removed android-support-v4.jar out of my additional libraries folder, no luck
- Tried to fix it with SDK-manager, which gives me an extra error: Error reading recommended items list

Socket error:
B4A Sdk Manager: 4.00
TempFolder = C:\Users\bigba\AppData\Roaming\ANYWHE~1\BASIC4~1\temp
DataFolder: C:\Users\bigba\AppData\Roaming\B4ASdkManager
SDK version: 6609375
Downloading: https://dl.google.com/dl/android/maven2/master-index.xml
error: java.net.SocketException: Connection reset by peer: socket write error

Can anybody help me with this?
 

jahswant

Well-Known Member
Licensed User
Longtime User

You have to delete your SDK folder and configure a new one.
 
Upvote 0

bigbadfred

Member
Licensed User
Longtime User

You have to delete your SDK folder and configure a new one.
Hi, thanks for your reply.
Unfortunately that didn't work.
Deinstalled and reinstalled Oracle Java 8, didn't work.
Deinstalled Oracle Java 8 and installed OpenJDK 11 also didn't work.
I have the impression it has something to do with the BundleTool, but I have no clue what that might be.
Perhaps "android-support-v4.jar" needs to be placed somewhere else?
I also tried that, didn't work out as well.

BundleTool error:
B4A Version: 11.80
Parsing code.    (0.10s)
    Java Version: 11
Building folders structure.    (0.03s)
Compiling code.    (0.12s)
    
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.    (0.03s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Compiling resources    (0.29s)
Linking resources    (1.65s)
Compiling generated Java code.    (1.95s)
Finding libraries that need to be dexed.    (0.01s)
Dex code    (1.97s)
Dex merge    (2.18s)
Copying libraries resources    (3.75s)
Building app bundle    Error
[BT:1.5.0] Error: Module files can be only in pre-defined directories, but found 'libs/android-support-v4.jar'.
com.android.tools.build.bundletool.model.exceptions.InvalidBundleException: Module files can be only in pre-defined directories, but found 'libs/android-support-v4.jar'.
    at com.android.tools.build.bundletool.model.exceptions.UserExceptionBuilder.build(UserExceptionBuilder.java:58)
    at com.android.tools.build.bundletool.validation.BundleFilesValidator.validateModuleFile(BundleFilesValidator.java:156)
    at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModulesUsingSubValidator(ValidatorRunner.java:81)
    at com.android.tools.build.bundletool.validation.ValidatorRunner.lambda$validateBundleModules$4(ValidatorRunner.java:64)
    at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:406)
    at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModules(ValidatorRunner.java:63)
    at com.android.tools.build.bundletool.validation.BundleModulesValidator.validate(BundleModulesValidator.java:82)
    at com.android.tools.build.bundletool.commands.BuildBundleCommand.execute(BuildBundleCommand.java:231)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:71)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:47)
 
Upvote 0

bigbadfred

Member
Licensed User
Longtime User
Unzip the archive preferable with 7zip, I hope you did that too

Also, your folder Android sdk path should not be a restricted path or path with spaces. Its advisable you put it on the C drive.
And Do not update the SDK after downloading
I specially downloaded 7-zip for that, even though Winrar works as well.
I did that just now again, did NOT run the SDKManager and still doesn't work.
Android SDK is extracted to c:\Android\, OpenJDK is extracted to c:\Java\jdk-11.0.1\.
The app compiles fine, installs perfectly on my cellphone (release and release obfuscated), it just does not want to build that app bundle.
 
Upvote 0

bigbadfred

Member
Licensed User
Longtime User
Physically check your <android sdk>\tools\bin folder to see if bundletool.jar is present

Also, redownload new B4A IDE and install
Bundletool.jar is present in C:\Android\build-tools\
Installed the latest b4a half an hour ago, still doesn't work.....
I'm banging the wall with my head in frustration, nothing seems to work.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
From that path "libs/android-support-v4.jar" I suspect it may be problem with the structure one of your libraries. I would try making a test app that includes the libraries you are using and see if it errors. Then by a process of elimination of each library see if you can eventually get it to build.
 
Upvote 0

bigbadfred

Member
Licensed User
Longtime User
From that path "libs/android-support-v4.jar" I suspect it may be problem with the structure one of your libraries. I would try making a test app that includes the libraries you are using and see if it errors. Then by a process of elimination of each library see if you can eventually get it to build.
That's a good suggestion and I will certainly try that, thanks!
But I still am struggling with the fact that my app will compile just fine, but building the app bundle fails...
Tomorrow I'll continue, today has been a lost day 🤬.
But thanks again!
 
Upvote 0

bigbadfred

Member
Licensed User
Longtime User
Hi, agraham!
I did what you suggested and limited the error to the library (wrapper) Valuebar by DonManfred.
I have no clue how to change wrappers, but maybe @DonManfred has an idea?
 
Upvote 0

bigbadfred

Member
Licensed User
Longtime User
Thanks Erel, I guess I'll have to find myself a nice alternative for valuebar.
Too bad, I liked it a lot and used it extensively in my app.
Thanks again!
 
Upvote 0
Top