Getting error in my libs - missing dependencies: jni_headers - android

I am trying to move my libs into product partition, and so that I have done all required changes and removed libandroid_runtime and libnativehelper because both are NON-ndk libs (both are using private apis). I was able to fix all the build time errors in android 30. But I am getting issue while building in Android S.
My 2 libs are using header_libs: ["jni_headers"], And when I try a full build or any app build I am getting below error for both libs -
FAILED: out/soong/.intermediates/mylib_path/android_product.S_arm_armv7-a-neon_cortex-a9_shared/mylib.so.toc
echo "module mylib missing dependencies: jni_headers{os:android,image:product.S,arch:arm_armv7-a-neon_cortex-a9,sdk:}" && false
module mylib missing dependencies: jni_headers{os:android,image:product.S,arch:arm_armv7-a-neon_cortex-a9,sdk:}
And if I remove this line I am getting missing #include <jni.h> header file error. So for the alternate purpose, I included jni.h file in my source code and now it's building perfectly. But I think this is not the right way to fix this.
Could you please look into this issue?
Thank you.

I encountered a similar issue and was able to solve it by adding jni_headers as a header lib.
Here is a copy of my Android.bp:
cc_library {
name: "libpinenote",
host_supported: false,
product_specific: true,
srcs: ["cpp/*.cpp"],
shared_libs: ["liblog"],
header_libs: ["jni_headers"],
cflags: [
"-Wno-error-unused-parameter",
"-fexceptions",
],
}

Related

libcrashpad_handler.so: library "libc++_shared.so" not found: needed by main executable

I followed the manual written by Bugsplat to build Crashpad for Android.
The build was successful and I got all necessary libraries. However I noticed that the prebuilt library libcrashpad_handler.so in Bugsplat's sample weighs about 26Mb. And mine is only 700Kb.
Moreover I got errors from linker when trying to catch signals from system.
/lib/arm64/libcrashpad_handler.so": library "libc++_shared.so" not found: needed by main executable
Is the instructions are not up-to-date on Bugsplat? Maybe there should be some extra_cflags passed to gn gen --args ?
Btw, I tried to include c++shared into apk with:
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
}
}
But i got no success to load it.
Really appreciate your assistance in building libcrashpad_handler.so.

React Native and Android - Integration with Existing Apps, add react native dir inside the android dir

Recently, we added to our native app a small module of React Native code.
When I follow the instructions in:
https://reactnative.dev/docs/integration-with-existing-apps
It's working fine, the RN module is working as expected.
The problem is that I need to place the RN directory inside the Android directory and not the other way around...
For example, this is how it's currently working:
Projects/ReactNativeProject/Android/
And this is how we need it to work:
Projects/Android/ReactNativeProject
The problem - AutoLinking won't work when I Changed the directories order...
With this CLI error:
Calling `[node, /Users/odedfunt/node_modules/#react-native-community/cli/build/bin.js, config]` finished with an exception. Error message: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
When I add this line to gradle it's not helping:
project.ext.react = [
enableHermes: false, // clean and rebuild if changing
cliPath: ["node", "-e", "console.log(require('react-native/cli').bin);"].execute([], projectDir).text.trim(),
cliPath: "$rootDir/react-native-project/node_modules/react-native/cli.js"
]
this is my settings.gradle
rootProject.name = "ReactTest200"
include ':app'
include ':react-native-svg'
def linkReactSVG = "$rootDir/react-native-project/node_modules/react-native-svg/android"
println("========================= link reactSVG: ${file(linkReactSVG)}")
project(':react-native-svg').projectDir = new File(rootProject.projectDir, linkReactSVG)
def linkSettings = "$rootDir/react-native-project/node_modules/#react-native-community/cli-platform-android/native_modules.gradle"
println("========================= linkSettings: ${file(linkSettings)}")
apply from: file(linkSettings); applyNativeModulesSettingsGradle(settings)
Does anyone knows what's the problem? I've been working on the for days and still couldn't figure it out...

Qt6 Android service with separate ".so" library and CMake

I have Qt 6.3 CMake-project that contains two subdirectories "app" and "service", i want include Android service .so library into result APK.
With qmake-project i can achieve this like that at app.pri:
contains(ANDROID_TARGET_ARCH, arm64-v8a) {
release: ANDROID_EXTRA_LIBS = $$OUT_PWD/../service/libservice_arm64-v8a.so
debug: ANDROID_EXTRA_LIBS = $$OUT_PWD/../service/libservice_arm64-v8a.so
}
with CMake i tried to set(QT_ANDROID_EXTRA_LIBS C:/workspace/build-test-Android_Qt_6_3_0_Clang_arm64_v8a-Debug/service/libservice_arm64-v8a.so)
at app->CMakeLists.txt and it has no effect.
Found that QT_ANDROID_EXTRA_LIBS is 'target property' and should be set via set_target_properties() then it adds .so into result.
set_target_properties(project_name PROPERTIES
QT_ANDROID_EXTRA_LIBS ${CMAKE_CURRENT_BINARY_DIR}/../service/libservice_${ANDROID_ABI}.so)

Android Activity under visual studio results in "undefined reference to" when attempting to build while referencing .a library

I have been dealing with this issue for a couple of days now. I Built the .so library using cmake under visual studio using the fallowing settings:
CMakeList.txt:
cmake_minimum_required (VERSION 3.8)
set(ANDROID_STL c++_static)
set(CMAKE_TOOLCHAIN_FILE C:/Microsoft/AndroidNDK/android-ndk-r21d/build/cmake/android.toolchain.cmake)
project("GetValsDudeLib").
So far I have been unable to find any examples online
set(CMAKE_SYSTEM_PROCESSOR x86)
set(CMAKE_ANDROID_ARCH arm)
set(CMAKE_SYSTEM_NAME ANDROID)
set(CMAKE_ANDROID_NDK "C:/Microsoft/AndroidNDK/android-ndk-r21d")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang5.0)
set(CMAKE_SYSTEM_VERSION 23) # API level
set(CMAKE_ANDROID_ARCH_ABI x86)
file(GLOB GetValsDudeSRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
add_library (GetValsDudeLib STATIC ${GetValsDudeSRC})
CMakeSetting.json
{
"configurations": [
{
"name": "x86-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "gcc-arm" ],
"variables": []
}
]
}
I added the the reference to the android native activity project:
Added headers folder path. Project properties C/C++ => Additional Include Directories.
Added library (.so) folder path. Project properties Linking => input=> Additional Library Directories.
Specified Library. Project properties Linking => input=> Library Dependencies (set that to "GetValsDudeLib").
After that I am able to create an instance of the class provided by the Library (GetValsDude) and build. It runs with no issues. But if I try to use a method of the object (AddOne(int)) it fails with the fallowing exception:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Android\3.0\Android.Common.targets(119,5): error MSB6006: "clang.exe" exited with code 1.
1> 263 Warning(s)
1> 1 Error(s)
1>
Looking into the logs I found the following:
...
1> C:\Microsoft\AndroidNDK\android-ndk-r21d\toolchains\x86-4.9\prebuilt\windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: Opened new descriptor 10 for "x86\Debug\libRevEngineAndroid.so"
1> undefined reference to 'GetValsDude::AddOne(int)'
...
So obviously there is a failure Linking GetValsDude header to the .so library.
Any help will be greatly appreciated.

Android NDK: unused import statement with header file

I'm trying to add tracing to my C++ project in Android Studio, I'm quite simply following the example in the docs to create a small profiling library in my app: https://developer.android.com/ndk/reference/group/tracing
I get an 'Unused import statement' message on the "#include " line in Android Studio as well as error: use of undeclared identifier 'ATrace_beginSection' compile errors. My CMakeLists.txt file for the library is:
project(profiling)
if(ANDROID)
include_directories(${ANDROID_SYSROOT}/usr/include)
message(STATUS "Including ${ANDROID_SYSROOT}/usr/include")
endif()
set(profiling_SRCS
profiling.cpp
)
set(profiling_HEADERS
profiling.h
)
add_library(profiling STATIC ${profiling_SRCS} ${profiling_HEADERS})
I've checked the cmake log for the "message" entry above, ANDROID_SYSROOT is indeed pointing to the correct location. The library shows up in the app->cpp section in Android Studio, the CMakeLists.txt file shows up in the External Build Files section, I've tried resyncing Gradle, I've tried cleaning and rebuilding, no dice. My targetSdkVersion is set to 27 in my build.gradle.
What am I missing?
Gaaaah. The problem was the minSdkVersion setting in build.gradle - trace.h has this at the top #if __ANDROID_API__ >= 23. For whatever it's worth, I also don't need to include ${ANDROID_SYSROOT}/usr/include in the CmakeLists.txt for this library... Hopefully this will help someone else in the future.
Your cmake file looks not complete. Try to add the path reference point using ${CMAKE_CURRENT_SOURCE_DIR}. E.g.
cmake_minimum_required(VERSION 3.4.1)
project(profiling)
if(ANDROID)
include_directories(${ANDROID_SYSROOT}/usr/include)
message(STATUS "Including ${ANDROID_SYSROOT}/usr/include")
endif()
set(profiling_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/profiling.cpp
)
set(profiling_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/profiling.h
)
add_library(profiling STATIC ${profiling_SRCS} ${profiling_HEADERS})

Categories

Resources