Skip to content

Commit

Permalink
- differentiate source class based on build variant in android ndk
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Oct 8, 2020
1 parent 30136cb commit f8fdd80
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
14 changes: 14 additions & 0 deletions app/build.gradle
Expand Up @@ -18,9 +18,23 @@ android {
}

buildTypes {
debug {
externalNativeBuild {
ndkBuild {
arguments "BUILD_VARIANT=debug"
}
}
}

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

externalNativeBuild {
ndkBuild {
arguments "BUILD_VARIANT=release"
}
}
}
}
compileOptions {
Expand Down
11 changes: 11 additions & 0 deletions app/src/debug/jni/protected.c
@@ -0,0 +1,11 @@
#include <jni.h>

JNIEXPORT jstring JNICALL
Java_com_mikepenz_credsshowcase_CustomApplication_getSdkKey(JNIEnv *env, jobject thiz, jobject context) {
return (*env)->NewStringUTF(env, "amazing-key-dev");
}

JNIEXPORT jstring JNICALL
Java_com_mikepenz_credsshowcase_CustomApplication_getSdkSecret(JNIEnv *env, jobject thiz, jobject context) {
return (*env)->NewStringUTF(env, "super-secure-secret-dev");
}
2 changes: 1 addition & 1 deletion app/src/main/jni/Android.mk
Expand Up @@ -5,6 +5,6 @@ include $(CLEAR_VARS)
LOCAL_MODULE := protected

# specify the src files to include in the native lib
LOCAL_SRC_FILES := protected.c
LOCAL_SRC_FILES := $(LOCAL_PATH)/../../$(BUILD_VARIANT)/jni/protected.c

include $(BUILD_SHARED_LIBRARY)
File renamed without changes.

0 comments on commit f8fdd80

Please sign in to comment.