libsomeip3.so not being loaded into the Android virtual device

251 views Asked by At

I am trying to run vsomeip Java API example from https://github.com/lixiaolia/ndk-someiplib. Build is successful but while launching the hello world service I am getting below error.

2022-11-12 21:23:15.966  3598-3598  MainActivity            com.example.vsomeiphelloworld        D  vsomeipBaseDir: /data/user/0/com.example.vsomeiphelloworld/cache/vsomeip
2022-11-12 21:23:15.966  3598-3598  MainActivity            com.example.vsomeiphelloworld        D  Os.getenv("VSOMEIP_BASE_PATH"): /data/user/0/com.example.vsomeiphelloworld/cache/vsomeip/
2022-11-12 21:23:16.024  3598-3598  ServiceVso...rldService com.example.vsomeiphelloworld        D  onCreate()
2022-11-12 21:23:16.024  3598-3598  ServiceVso...rldService com.example.vsomeiphelloworld        D  onStartCommand()
2022-11-12 21:23:16.051  3598-3598  AndroidRuntime          com.example.vsomeiphelloworld        D  Shutting down VM
2022-11-12 21:23:16.052  3598-3598  AndroidRuntime          com.example.vsomeiphelloworld        E  FATAL EXCEPTION: main
                                                                                                    Process: com.example.vsomeiphelloworld, PID: 3598
                                                                                                    java.lang.UnsatisfiedLinkError: dlopen failed: library "libvsomeip3.so" not found: needed by /data/app/~~flBAHgGOZ1GR2qSnIduRoQ==/com.example.vsomeiphelloworld-a_eINFrhrnN_QujTru-l2w==/base.apk!/lib/x86_64/libServiceVsomeipHelloWorldServiceJNI.so in namespace classloader-namespace
                                                                                                        at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
                                                                                                        at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
                                                                                                        at java.lang.System.loadLibrary(System.java:1664)
                                                                                                        at com.example.vsomeiphelloworld.ServiceVsomeipHelloWorldService.onStartCommand(ServiceVsomeipHelloWorldService.java:39)
                                                                                                        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4320)
                                                                                                        at android.app.ActivityThread.access$1800(ActivityThread.java:237)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1951)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loop(Looper.java:223)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7664)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
---------------------------- PROCESS ENDED (3598) for package com.example.vsomeiphelloworld ----------------------------

I have not yet built the Java app since the C++ library itself is being deleted as soon as the Task :app:buildCMakeDebug[x86_64] is over. The cmake file is as below. Strangely the other .so files remain till end of the build - libvsomeip3-cfg, libvsomeip3-e2e, libvsomeip3-sd. Top level Cmake file is as below.

cmake_minimum_required(VERSION 3.4.1)

project(vsomeip-hello-world)


list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

add_subdirectory(external/boost-cmake)
add_subdirectory(external/vsomeip)
add_subdirectory(external/vsomeip/examples/hello_world)
#add_subdirectory(app/src/main/cpp)

Note: If I uncomment the last line I get "missing libvsomeip3-cfg.so" which is a separate question. build.gradle file is as below

plugins {
    id 'com.android.application'
}

android {
    namespace 'com.example.vsomeiphelloworld'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.vsomeiphelloworld"
        minSdk 30
        targetSdk 33
        versionCode 1
        versionName "1.0"

        ndk {
            abiFilters 'x86_64'
        }
    }

    externalNativeBuild {
        cmake {
            path file('../CMakeLists.txt')
            version '3.18.1'
        }
    }

    ndkVersion '22.1.7171670'
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
}

AGP: 7.2.0 Gradle version: 7.5 NDK version: 22.1.7171670 Android Studio version: 2021.3.1 Patch 1 CMake version: 3.18.1 SDK version: 33

Someone kindly help me understand the issue. A quick fix is also welcome given my project timeline.

1

There are 1 answers

0
Scarlet On

Use 3.12.4 instead, it worked for me.