Painful Unity project export to Android each build (I'm doing something wrong)

You can create your own Gradle file. Put it in Plugins/Android folder and call it mainTemplate.gradle It will use that.

As far as I know, there is no way to rebuild just part of it. Unity does not create java files from the c# code. It creates its own modules and uses them directly.

BTW, why are you exporting at all? Why not compile directly to your device?


I just wanted an additional answer for this question even though it is a bit old (just in case anyone else in the future is wondering about this like me). I personally need to make use of both Android Studio and Unity so making a plugin wasn't really an option for me.

Now I have a custom gradle file as explained in the accepted answer. However I have also added an additional resource folder (Explained well by Android here: https://developer.android.com/studio/write/add-resources.html).

You basically just have to edit your custom gradle file to add paths to both resource directories. Add the resources you don't want Unity to overwrite to the other resource folder.

Now every time you rebuild to the project the resources remain and you don't have to copy them back in.