BR: Projucer/Android Gradle builds with RelWithDebInfo when selecting Release build variant

This is confirmed by viewing the result in two ways:

  1. editing the generated CMakeLists.txt with message (FATAL_ERROR "${CMAKE_BUILD_TYPE}")
  2. viewing the build output (see screenshot)

image

It looks like the solution is to correctly and conditionally add "-DCMAKE_BUILD_TYPE=Release" or "-DCMAKE_BUILD_TYPE=Debug" .

PR fixing this: Android: Fixed Projucer's generation of CMakeLists.txt. by jrlanglois · Pull Request #1115 · juce-framework/JUCE · GitHub

What issues is this causing? It sounds like this is the expected behaviour for the Android Gradle Plugin (see the last post here: Google Issue Tracker). Apparently, when Gradle builds an APK for distribution, it strips all debugging symbols automatically as a separate build step. I’m inclined to stick with the default build behaviour as much as possible, unless this is causing specific problems.

In terms of issues caused by using RelWithDebInfo, it looks like we currently set CMAKE_CXX_FLAGS_RELEASE when building for release mode, and these flags may not get applied if the build type is actually set to RelWithDebInfo. However, I suspect we could switch to just using CMAKE_CXX_FLAGS here.

It’s a low impact issue but it’s still wrong.

As I mentioned in my follow up reply, CMAKE_BUILD_TYPE is the way to go here. Setting that properly to Release when selecting the Release build variant sets the process up accordingly, and is displayed accordingly by Cmake and Android Studio/Gradle.

Edit:

Having a read the post you shared, I see what you mean now. The problem here is that it doesn’t really jive with Cmake I guess - the Gradle step for managing stripping debug symbols can be missed if you hand rolled one yourself but even then… PJ sorts that out for you just fine.

I don’t know whether the behaviour you’re suggesting is desirable. The default behaviour of Android Studio is to use RelWithDebInfo for release builds - if building a release APK will strip symbols anyway, then being able to debug the release build seems useful. As long as all of the other “Release” mode flags specified in the Projucer are used when CMake is building in RelWithDebInfo mode, then I think the resulting app will be built correctly.

I can’t say I’ve come across this problem in the past with other Cmake based projects, non-JUCE. The expectation from Android Studio appears inconsistent with vanilla Cmake.

That being said, a user on the post you linked mentioned:

If the user explicitly sets CMAKE_BUILD_TYPE then we use that.

So if I ended up hand rolling my own Cmake files which would support Android (someday we’ll have the time to drop the Projucer in favour of that), the behaviour would be as expected where Release is in fact Release, and RelWithDebInfo is a separate build type (because Cmake provides 4 separate build types).

Anyway – let’s call this a false alarm and TIL about more Android Studio weirdness!