Issue
I use native C++ with my Android project.
In Java or Kotlin we can use BuildVersion.Code
to get the Android code from the Gradle file. How can I get this version code in C++?
Solution
This is working for me:
jclass build_config_class = env->FindClass("com/example/app/BuildConfig");
jfieldID version_code_id = env->GetStaticFieldID(build_config_class, "VERSION_CODE", "I");
jfieldID version_name_id = env->GetStaticFieldID(build_config_class, "VERSION_NAME",
"Ljava/lang/String;");
int version_code = env->GetStaticIntField(build_config_class, version_code_id);
jstring version_name = (jstring) env->GetStaticObjectField(build_config_class, version_name_id);
You need to change com/example/app in the code to match your package name.
Answered By - gioravered
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.