all!
I am trying to get Gradle to generate different files (Android.mk and Application.mk) for release and debugging. By default, the gradle android plugin that does this does not suit me, because it does not allow changing Application.mk, I want to. The main problem is that I cannot determine the current type of assembly. I tried the following:
android { ... defaultConfig { project['CONFIGURATION_FLAGS'] = '' project['APP_ABI'] = '' project['APP_PLATFORM'] = 'android-9' project['APP_STL'] = 'gnustl_static' project['NDK_TOOLCHAIN_VERSION'] = 'clang' } buildTypes { release { project['CONFIGURATION_FLAGS'] = '-fvisibility=hidden' project['APP_ABI'] = 'armeabi x86' } debug { project['CONFIGURATION_FLAGS'] = '-g -DDEBUG -DENABLE_LOG' project['APP_ABI'] = 'armeabi' } } } task processTemplates { def templatesDir = System.getProperty('user.dir') + '/app/templates' def jniDir = System.getProperty('user.dir') + '/app/src/main/jni' // Android.mk def configFlags = project['CONFIGURATION_FLAGS'] def androidMk = file(templatesDir + '/Android.mk').text androidMk = androidMk.replaceAll '<CONFIGURATION_FLAGS>', configFlags def newAndroidMk = new File(jniDir + '/Android.mk') newAndroidMk.text = androidMk // Application.mk def appAbi = project['APP_ABI'] def appPlatform = project['APP_PLATFORM'] def appStl = project['APP_STL'] def toolchain = project['NDK_TOOLCHAIN_VERSION'] def applicationMk = file(templatesDir + '/Application.mk').text applicationMk = applicationMk.replaceAll '<APP_ABI>', appAbi applicationMk = applicationMk.replaceAll '<APP_PLATFORM>', appPlatform applicationMk = applicationMk.replaceAll '<APP_STL>', appStl applicationMk = applicationMk.replaceAll '<NDK_TOOLCHAIN_VERSION>', toolchain def newApplicationMk = new File(jniDir + '/Application.mk') newApplicationMk.text = applicationMk }
But I found that the settings are configured 2 times, that is, for each type of assembly, regardless of the current type of assembly. This leads to the fact that for any type of assembly it sets debugging options. Can someone advise me how to solve this problem?
source share