Loading Android.bp +19 −7 Original line number Diff line number Diff line Loading @@ -56,15 +56,24 @@ cc_library_shared { srcs: [ "jni/network_stack_utils_jni.cpp" ], sdk_version: "current", shared_libs: [ "liblog", "libcutils", "libnativehelper", ], static_libs: [ "libpcap", "libnativehelper_compat_libc++", ], // We cannot use plain "libc++" here to link libc++ dynamically because it results in: // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't // build because soong complains of: // module NetworkStack missing dependencies: libc++_shared // // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries // we depend on do not dynamically link libc++. This is currently the case, because liblog is // C-only and libnativehelper_compat_libc also uses stl: "c++_static". // // TODO: find a better solution for this in R. stl: "c++_static", cflags: [ "-Wall", "-Werror", Loading @@ -79,7 +88,10 @@ java_defaults { static_libs: [ "NetworkStackBase", ], jni_libs: ["libnetworkstackutilsjni"], jni_libs: [ "libnativehelper_compat_libc++", "libnetworkstackutilsjni", ], // Resources already included in NetworkStackBase resource_dirs: [], jarjar_rules: "jarjar-rules-shared.txt", Loading jni/network_stack_utils_jni.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ #include <string> #include <nativehelper/JNIHelp.h> #include <utils/Log.h> #include <android/log.h> namespace android { constexpr const char NETWORKSTACKUTILS_PKG_NAME[] = "android/net/util/NetworkStackUtils"; Loading Loading @@ -249,7 +249,7 @@ static const JNINativeMethod gNetworkStackUtilsMethods[] = { extern "C" jint JNI_OnLoad(JavaVM* vm, void*) { JNIEnv *env; if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { ALOGE("ERROR: GetEnv failed"); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "ERROR: GetEnv failed"); return JNI_ERR; } Loading tests/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ android_test { "liblog", "liblzma", "libnativehelper", "libnativehelper_compat_libc++", "libnetworkstacktestsjni", "libnetworkstackutilsjni", "libpackagelistparser", Loading Loading @@ -99,5 +100,4 @@ cc_library_shared { "libapf", "libpcap", ], } Loading
Android.bp +19 −7 Original line number Diff line number Diff line Loading @@ -56,15 +56,24 @@ cc_library_shared { srcs: [ "jni/network_stack_utils_jni.cpp" ], sdk_version: "current", shared_libs: [ "liblog", "libcutils", "libnativehelper", ], static_libs: [ "libpcap", "libnativehelper_compat_libc++", ], // We cannot use plain "libc++" here to link libc++ dynamically because it results in: // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't // build because soong complains of: // module NetworkStack missing dependencies: libc++_shared // // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries // we depend on do not dynamically link libc++. This is currently the case, because liblog is // C-only and libnativehelper_compat_libc also uses stl: "c++_static". // // TODO: find a better solution for this in R. stl: "c++_static", cflags: [ "-Wall", "-Werror", Loading @@ -79,7 +88,10 @@ java_defaults { static_libs: [ "NetworkStackBase", ], jni_libs: ["libnetworkstackutilsjni"], jni_libs: [ "libnativehelper_compat_libc++", "libnetworkstackutilsjni", ], // Resources already included in NetworkStackBase resource_dirs: [], jarjar_rules: "jarjar-rules-shared.txt", Loading
jni/network_stack_utils_jni.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ #include <string> #include <nativehelper/JNIHelp.h> #include <utils/Log.h> #include <android/log.h> namespace android { constexpr const char NETWORKSTACKUTILS_PKG_NAME[] = "android/net/util/NetworkStackUtils"; Loading Loading @@ -249,7 +249,7 @@ static const JNINativeMethod gNetworkStackUtilsMethods[] = { extern "C" jint JNI_OnLoad(JavaVM* vm, void*) { JNIEnv *env; if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { ALOGE("ERROR: GetEnv failed"); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "ERROR: GetEnv failed"); return JNI_ERR; } Loading
tests/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ android_test { "liblog", "liblzma", "libnativehelper", "libnativehelper_compat_libc++", "libnetworkstacktestsjni", "libnetworkstackutilsjni", "libpackagelistparser", Loading Loading @@ -99,5 +100,4 @@ cc_library_shared { "libapf", "libpcap", ], }