Projucer: the contents of Build/Android/app/src/main/java/* are wiped out every time the Projucer project is saved


I need to extend the default created Juce Activity class, and also to add more Java sources / packages / jars.

Is this a bug or is there a place where I should put my custom java source files?
As of now if I put them on the side of the Juce Activity class all files and subfolders are deleted every time the Projucer project is saved.


I just discovered that this is not a new issue (1+ year ago thread opened by @adamski with the very same problem).

@fabian any news on this?

I hope something can be done beside forking JUCE…


Hi @Mathieu,

I’m sorry about your java source file being overridden by the Projucer. The Projucer’s behaviour of wiping any files that is in the Builds sub-directory is a common pain point for JUCE new-comers (this doesn’t happen only on Android - but with any exporter) and we are thinking about ways for the Projucer to warn users when it detects that the user has made changes to files inside the Builds folder.

However, JUCE does support you using your own activity class although it is a bit cumbersome and also may change in later JUCE versions. Basically, you need to create a separate Activity class (in separate java file) which inherits from JUCE’s activity class. You can then specify your custom activity class in the Projucer:

To make life a bit easier, the Projucer will not wipe any Java files in the Build folder which the Projucer did not create, so you can put your sub-class next to JUCE’s java activity source file.

Thanks for your answer.

However I’ve put my Java file extending the JUCE Activity right on its side and… it’s gone.
Actually, everything below the src sub-folder seems to be deleted.

Maybe I can try to find the line of code that does that.

@fabian: found it
(JUCE Code is nicely organized :slight_smile:)

Called by AndroidProjectExporter::create()

Thanks. This is fixed on develop with commit 662cf06.

Great, thanks to you! :slight_smile: