Android Question [SOLVED] I constantly have to manually delete the Objects folder in B4A & B4J

Peter Simpson

Expert
Licensed User
Longtime User
The title says it all,
For months now, and I do mean months, in both Windows 10 and Windows 11, I've been receiving these messages. When I do receive these messages in both B4A and B4j (in all the current and previously created projects, and I do mean all previously created projects going back years), I have to go into the projects folder and manually delete the Objects folder (the Objects folder deletes with no issues whatsoever), I then clean the project (Ctrl + P) and I can then run the program in release mode (only once) (F5) to build the release applications, .apk file in B4A and .jar file for B4J. Please note that I can only do this once, on the second attempt to run the project in release mode (F5), I will receive the access denied messages and I then have to delete the Objects folder again. Please note that I do not have this issue in debug mode, only in release Mode. I have also tried running B4A as an Administrator (by right clicking on the shortcut icons) and I still have the same issue.

Yes I have deleted everything, and reinstalled it all again from scratch including B4A and B4J, OpenJDK x + OpenJFX, and Android SDK + Required Resources for B4A.

When I receive these messages, I have to go to the project folder and delete the Objects folder. Actually I only need to delete the files mentioned, but it is far quicker to just delete the whole Objects folder. This only happens in release mode and NOT in debug mode.

I've searched the forum but it appears that I'm the only person with this issue, which after months of putting up with this, it has finally got on my nerves today as I had to quickly update an app for a client when this happened again, thus annoying me as I should not be coding for a few days.

When it comes to my laptops, absolutely nothing has changed as far as I'm concerned. The B4X project folders have been in my Documents > B4X > ... for absolutely years now, actually since Tue, 3 Apr 2012 to be exact. So no, it has absolutely nothing to do with the folder structure before someone mentions that.

I presume that it's going to be something extremely simple that I'm missing here. I have also turned off my antivirus, it still does it for me on the second Run (F5) attempt.

B4A - When I click Run (F5)
1752244508663.png


B4A - When I click on clean project (Ctrl + P)
1752244893551.png


B4J - When I click Run (F5)
1752244600534.png


B4J - When I click on clean project (Ctrl + P)
1752244989672.png



I've tried to be as thorough as possible with laying out the issue that I'm having.

Thanks in advance for the responses.
 

Attachments

  • 1752245019761.png
    1752245019761.png
    39.3 KB · Views: 46

Daestrum

Expert
Licensed User
Longtime User
is it possible you have the file open in another app ? Sometimes I have had similar from file manager if prevew is on, locking a file.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
ChatGPT's o3 model (advanced reasoning model) says this:


Thought for 1m 2s
Bottom line: something outside the IDE is putting a lock on the Objects\… files between builds, and 99 % of the time that “something” is OneDrive / Dropbox / Google Drive (or an AV real-time scanner that’s watching the same folder).
Debug builds squeak through because they barely touch the Objects tree; Release builds wipe and recreate it, and the sync-engine still has a handle open, so Windows says “access denied”.

Why it suddenly started happening​

  • Windows 10/11 updates have quietly switched many PCs to the Documents ↦ OneDrive “known-folder redirection”.
  • Your project sits under C:\Users\Peter\Documents\B4X\..., which is now a OneDrive-controlled folder.
  • OneDrive (or any similar sync / backup / AV) keeps files open while it hashes, uploads, or scans them. The next Release build tries to delete the folder and Windows refuses.
Erel has pointed at exactly this root cause before — “Dropbox / Google Drive synchronized folder or an over-aggressive anti-virus” (https://www.b4x.com/android/forum/threads/access-denied-objects-directory.140583/) – and a recent thread shows moving the project out of OneDrive eliminates the error completely (https://www.b4x.com/android/forum/threads/access-denied-situation.167262/).

Quick fixes you can try right now​

#FixHow to do itEffect on build
1Move the whole project out of Documentse.g. C:\B4XProjects\MyApp (a plain, local NTFS folder). Point the IDE to the new path.99 % of cases – immediately solves it.
2Pause OneDrive (or Dropbox / GDrive) while compilingOneDrive task-tray → Pause syncing for 2 hours.Works, but you’ll have to remember every time.
3Tell OneDrive to ignore that pathSettings → Sync & backup → Choose folders → untick your B4X folder.Permanent; no more locks, still lets the rest of Documents sync.
4Add a Defender & AV exclusionWindows Security → Virus & threat protection → Manage settings → Exclusions. Add your ...\B4X\ root.Stops real-time scanning locks if AV is the culprit.
5Make the folder “Always keep on this device”Right-click folder → OneDrive → Always keep on this device.Forces offline copy – reduces but doesn’t always remove locks.
6Close File Explorer windows showing the Objects folder and disable the Preview-paneExplorer keeps a read-handle on JAR/APK icons.Minor, but can tip the balance.

(Try #1 first – it’s the fastest litmus-test.)
 
Last edited:
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
is it possible you have the file open in another app ? Sometimes I have had similar from file manager if prevew is on, locking a file.
I will say no to that one, but I do keep coming back to the Antivirus (it doesn't matter which one I run), but I disable it and it still happens. I then make sure that Windows AV is off too, as I know that can cause some crazy issues, but to no avail.

I know that you're correct, what what is keeping the files open I have absolute no idea. I do now for a fact that it's NOT the IDEs though.

It's happening on both my development laptops (Win 10 & 11), that's why I originally though AV. Even though all AVs are off lately whilst I'm working in B4A & B4J, I still think it could have something to do with them. I'll actually uninstall them and disable Win Defender to see

Thank you, I will look further into this issue, I just need to find what's locking the files as it really annoyed me today, and I don't really get annoyed whilst programming, ever.

Cheers...
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
ChatGPT's o3 model (advanced reasoning model) says this:


Thought for 1m 2s
Bottom line: something outside the IDE is putting a lock on the Objects\… files between builds, and 99 % of the time that “something” is OneDrive / Dropbox / Google Drive (or an AV real-time scanner that’s watching the same folder).
Debug builds squeak through because they barely touch the Objects tree; Release builds wipe and recreate it, and the sync-engine still has a handle open, so Windows says “access denied”.
I agree completely, but I stopped live synchronisation of backups years ago, but I do backup multiple times a day during my breaks away from my laptops.
I don't use OneDrive at all, I don't use Dropbox for backing up my code, and the same goes for Google Drive. I have my own backup solution which is both onsite and offsite.


Why it suddenly started happening​

  • Windows 10/11 updates have quietly switched many PCs to the Documents ↦ OneDrive “known-folder redirection”.
  • Your project sits under C:\Users\Peter\Documents\B4X\..., which is now a OneDrive-controlled folder.
  • OneDrive (or any similar sync / backup / AV) keeps files open while it hashes, uploads, or scans them. The next Release build tries to delete the folder and Windows refuses.
Erel has pointed at exactly this root cause before — “Dropbox / Google Drive synchronized folder or an over-aggressive anti-virus” (https://www.b4x.com/android/forum/threads/access-denied-objects-directory.140583/) – and a recent thread shows moving the project out of OneDrive eliminates the error completely (https://www.b4x.com/android/forum/threads/access-denied-situation.167262/).

Quick fixes you can try right now​

#FixHow to do itEffect on build
1Move the whole project out of Documentse.g. C:\B4XProjects\MyApp (a plain, local NTFS folder). Point the IDE to the new path.99 % of cases – immediately solves it.
2Pause OneDrive (or Dropbox / GDrive) while compilingOneDrive task-tray → Pause syncing for 2 hours.Works, but you’ll have to remember every time.
3Tell OneDrive to ignore that pathSettings → Sync & backup → Choose folders → untick your B4X folder.Permanent; no more locks, still lets the rest of Documents sync.
4Add a Defender & AV exclusionWindows Security → Virus & threat protection → Manage settings → Exclusions. Add your ...\B4X\ root.Stops real-time scanning locks if AV is the culprit.
5Make the folder “Always keep on this device”Right-click folder → OneDrive → Always keep on this device.Forces offline copy – reduces but doesn’t always remove locks.
6Close File Explorer windows showing the Objects folder and disable the Preview-paneExplorer keeps a read-handle on JAR/APK icons.Minor, but can tip the balance.

(Try #1 first – it’s the fastest litmus-test.)

Hmm, I will pause both Dropbox and Google drive even though they are NOT set to backup anything in My Documents folder. I am seeing a common theme here though, so thank you. I already disable my AV, but I'll look more into it.

Both @Daestrum and yourself have got me thinking out of the box, I'll look further into this but from another angle. Obviously I have a package on both laptops that is locking the files of both new and older projects, but what? Backup and AV wise nothing has changed in years, so something has obviously been updated and reset some default settings of mine, obviously.

Cheers...
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
a little poweshell to see who owns the file when it happens
B4X:
$path = "C:\Path\To\Your\File.txt"
try {
    $owner = (Get-Acl $path).Owner
    Write-Host "Owner of '$path' is: $owner"
} catch {
    Write-Host "Unable to access '$path'. Error: $($_.Exception.Message)"
}
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
I too have had this happen several times recently (in B4A). I got called away on jury service so haven't pursued it past moving my app well away from OneDrive and resetting security on the entire structure. Neither have fixed the issue. Windows 11, default Windows security.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Also avoid putting sources/apps in Documents folder, it's a protected folder that Defender and OneDrive will monitor all the time and can lock files.

Use something like C:\B4X - Defender will still check, but not so aggressively.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
The title says it all,
For months now, and I do mean months, in both Windows 10 and Windows 11, I've been receiving these messages. When I do receive these messages in both B4A and B4j (in all the current and previously created projects, and I do mean all previously created projects going back years), I have to go into the projects folder and manually delete the Objects folder (the Objects folder deletes with no issues whatsoever), I then clean the project (Ctrl + P) and I can then run the program in release mode (only once) (F5) to build the release applications, .apk file in B4A and .jar file for B4J. Please note that I can only do this once, on the second attempt to run the project in release mode (F5), I will receive the access denied messages and I then have to delete the Objects folder again. Please note that I do not have this issue in debug mode, only in release Mode. I have also tried running B4A as an Administrator (by right clicking on the shortcut icons) and I still have the same issue.

Yes I have deleted everything, and reinstalled it all again from scratch including B4A and B4J, OpenJDK x + OpenJFX, and Android SDK + Required Resources for B4A.

When I receive these messages, I have to go to the project folder and delete the Objects folder. Actually I only need to delete the files mentioned, but it is far quicker to just delete the whole Objects folder. This only happens in release mode and NOT in debug mode.

I've searched the forum but it appears that I'm the only person with this issue, which after months of putting up with this, it has finally got on my nerves today as I had to quickly update an app for a client when this happened again, thus annoying me as I should not be coding for a few days.

When it comes to my laptops, absolutely nothing has changed as far as I'm concerned. The B4X project folders have been in my Documents > B4X > ... for absolutely years now, actually since Tue, 3 Apr 2012 to be exact. So no, it has absolutely nothing to do with the folder structure before someone mentions that.

I presume that it's going to be something extremely simple that I'm missing here. I have also turned off my antivirus, it still does it for me on the second Run (F5) attempt.

B4A - When I click Run (F5)
View attachment 165293

B4A - When I click on clean project (Ctrl + P)
View attachment 165295

B4J - When I click Run (F5)
View attachment 165294

B4J - When I click on clean project (Ctrl + P)
View attachment 165296


I've tried to be as thorough as possible with laying out the issue that I'm having.

Thanks in advance for the responses.
The same thing happened to me a while back when Windows updated the system. The solution was to grant full permissions to the folders where the projects are located.older

Test
permissions for folders and all subfolders
This solved my problems.

1752271275269.png
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hello Daestrum
Also avoid putting sources/apps in Documents folder,
I have to respectfully disagree with premise. As an ex network engineer (running my own business), I always said to my clients and customers always save everything in the Documents folder and to back it up religiously, and try not to save on the desktop either. You will be surprised how many people backup their Documents folder but not their desktop where mysteriously they enjoy saving important files for quick reference. No, I don't save any documents in folders directly off the C drive, never.

Just my 2 cents, don't hate me for it ;)
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Firstly I would like to thank everyone for their replies to my original post, this is why the B4X community is easily the best on the internet, bar none.

So I've just got back home from a night out with the lads up town when I had this thought, yes, after a few drinks ;)

Even though I originally disabled the antivirus I was still encountering issues. So I decided to uninstall the AV and quickly Run (F5) a few projects multiple times in B4A and B4J, it worked.

I quickly ran a couple of cleaners to remove all references of the AV (which I'm not mentioning any names as I'm not getting into an AV branding chat in here). Once I did that I reinstalled the AV and reapplied the B4X and VS folders exception like I always add to my AVs and there you have it, everything is working once again like it was previously doing months ago.

I have absolutely no idea why even when I disabled the AV on previous tests, it just didn't actually stop monitoring files even though it claimed it was disabled. I presume that it was a faulty update that caused the issues that I was having. An AV uninstall and clean followed by a fresh install fixed the issues.

I've never had this issue before, I never ever turn off my AV, I only turned it off as I was trying to fix this issue.

Anyway, everything is working 100% again, even with the AV enabled and monitoring, so I'm a happy chappy again.

Thank you all again for you replies, and I'll catch you all on the flip side.


Cheers 🍻
 
Last edited:
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
What AV are you running? You can add exceptions (files and entire folders). Defender and MalwareBytes have both given me similar issues in the past.

I wouldn’t turn it off though - use the exception capability that why it exists.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
What AV are you running? You can add exceptions (files and entire folders). Defender and MalwareBytes have both given me similar issues in the past.

I wouldn’t turn it off though - use the exception capability that why it exists.
Hello,
Thank you for asking, but as I stated above, I'm not mentioning any AV names as I'm not getting into any discussions regarding this AV vs that AV vs another branded AV and that one should switch to yet another AV etc etc etc. I also stated above that I always add exceptions and that means that I already added exceptions for both the B4X and VS folders in my documents.

The problem appears to be that the AV program itself (not the definition, that's monthly) was last automatically updated a few months ago, and the update caused the issues.

Anyway it's sorted now, cheers 👍
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Hello,
Thank you for asking, but as I stated above, I'm not mentioning any AV names as I'm not getting into any discussions regarding this AV vs that AV vs another branded AV and that one should switch to yet another AV etc etc etc. I also stated above that I always add exceptions and that means that I already added exceptions for both the B4X and VS folders in my documents.

The problem appears to be that the AV program itself (not the definition, that's monthly) was last automatically updated a few months ago, and the update caused the issues.

Anyway it's sorted now, cheers 👍
That wasn’t why I was asking, like I said I’ve experienced the problem with AVs. Pretty much all AVs have the ability to add exclusions.

Also for the benefit of others who may run into the issue, I find sometimes when adding an exclusion you need to reboot for it to pick up the change.

Peter, your tone in this whole thread is really condescending. People are just trying to help you…
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
That wasn’t why I was asking, like I said I’ve experienced the problem with AVs. Pretty much all AVs have the ability to add exclusions.

Also for the benefit of others who may run into the issue, I find sometimes when adding an exclusion you need to reboot for it to pick up the change.

Peter, your tone in this whole thread is really condescending. People are just trying to help you…
My tone is NOWHERE NEAR condescending. I've learned over the years to just get straight to the point with absolutely no BS extra content necessary. I have all the info I could think of included in the first post, I thanked people for helping me (and they did help me) including you with a thumbs up emoji, and you have the dam nerve to call me condescending, GTFOH, really.

What you NEED to do is Google the word condescending for it's actual meaning, because that wasn't me.

All these years I've never ever had anything bad to say to you or about you. So I'll just say, actually no I request that you add me to you block list, thus you don't have to ready my apparent condescending posts anymore.
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
My tone is NOWHERE NEAR condescending. I've learned over the years to just get straight to the point with absolutely no BS extra content necessary. I have all the info I could think of included in the first post, I thanked people for helping me (and they did help me) including you with a thumbs up emoji, and you have the dam nerve to call me condescending, GTFOH, really.

What you NEED to do is Google the word condescending for it's actual meaning, because that wasn't me.

All these years I've never ever had anything bad to say to you or about you. So I'll just say, actually no I request that you add me to you block list, thus you don't have to ready my apparent condescending posts anymore.
Given your reaction above you’re clearly having a moment. For a supposed “expert” your behaviour is a bit over the top.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
I know I'm a bit late to this party, but I'm surprised that nobody seemed to suggest to just figure out what process is keeping the file open. Here's a command line tool to do just that:


I've used it a couple of times over the years and it's been very helpful to me.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
I know I'm a bit late to this party, but I'm surprised that nobody seemed to suggest to just figure out what process is keeping the file open. Here's a command line tool to do just that:


I've used it a couple of times over the years and it's been very helpful to me.
Thank you for the response.
Yours and the response below from @Daestrum (which I originally missed), would have helped me to get to the answer a lot sooner. I should have thought about doing this myself, cheers 🍻

Hey, I started watching Season 2 of a show with your username in its title a couple of nights ago. I'm enjoying it 😉

a little poweshell to see who owns the file when it happens
B4X:
$path = "C:\Path\To\Your\File.txt"
try {
    $owner = (Get-Acl $path).Owner
    Write-Host "Owner of '$path' is: $owner"
} catch {
    Write-Host "Unable to access '$path'. Error: $($_.Exception.Message)"
}

Both responses have been noted for any future issues 👍
 
Last edited:
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I read everything, but I’m not sure if the issue is actually resolved.
I’ve also been experiencing this problem for a while now.


When I need to work on a new version of an app, I copy the entire source folder to my desktop, sometimes renaming the folder to something like “vs 4.12 next release”.
I do this because if I work directly from its original location (under OneDrive), every time I compile, a ton of data gets synced.


Well, recently I’ve started running into this “access denied” issue too.
My workaround is to delete the obj folder (after saving the only file I care about — the app icon under res/drawable), and then after the first compilation, I copy that file back in.
 
Upvote 0
Top