My native library contains logs that I would like to delete at compile time. Logs are displayed by determining the macroprocessor preprocessor ENABLE_DEBUGin LOCAL_CFLAGSthe following manner:
include $(CLEAR_VARS)
LOCAL_MODULE := native-stuff
LOCAL_SRC_FILES := Native.cpp
LOCAL_LDLIBS := -llog
LOCAL_CFLAGS := -DENABLE_DEBUG
include $(BUILD_SHARED_LIBRARY)
I am creating an application using Gradle through Android Studio, and I would like to have another Android.mk file without LOCAL_CFLAGS := -DENABLE_DEBUGfor releases, effectively disabling logging.
I tried to do this by creating folders release/jniunder srcand placing a copy of Android.mk without CFLAGS. It builds and deploys successfully, but I still see the logs. Here is mine build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
sourceSets {
main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [];
}
release {
jni.srcDirs = [];
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
task ndkBuild(type: Exec) {
commandLine "$androidNdkHome/ndk-build", '-C', file('src/main/jni').absolutePath
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.2'
}
My project structure is as follows:
src/
main/
jni/
Android.mk
release/
jni/
Android.mk
Can I do what I want?