Skip to content

Commit

Permalink
hookup the rest of the android code
Browse files Browse the repository at this point in the history
  • Loading branch information
rogchap committed Sep 14, 2020
1 parent 2c46967 commit e97c64a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions android/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ add_library( # Sets the name of the library.
# Provides a relative path to your source file(s).
native-lib.cpp )

add_library(lib_foo SHARED IMPORTED)
set_property(TARGET lib_foo PROPERTY IMPORTED_NO_SONAME 1)
set_target_properties(lib_foo PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/${CMAKE_ANDROID_ARCH_ABI}/libfoo.so)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/${CMAKE_ANDROID_ARCH_ABI}/)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
Expand All @@ -39,6 +44,8 @@ find_library( # Sets the name of the path variable.
target_link_libraries( # Specifies the target library.
native-lib

lib_foo

# Links the target library to the log library
# included in the NDK.
${log-lib} )
9 changes: 8 additions & 1 deletion android/app/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#include <jni.h>
#include <string>

#include "libfoo.h"

extern "C" {
jstring
Java_com_rogchap_foobar_MainActivity_reverse(JNIEnv* env, jobject, jstring str) {
return str;
const char* cstr = env->GetStringUTFChars(str, 0);
char* cout = reverse(const_cast<char*>(cstr));
jstring out = env->NewStringUTF(cout);
env->ReleaseStringUTFChars(str, cstr);
free(cout);
return out;
}
}

0 comments on commit e97c64a

Please sign in to comment.