Hi. I’m trying to build optee_example CA as an .apk.
I want to make test CA as an apk file so that user can just touch to execute the application.
I think that if I copy hello_world example code to my increment.cpp file with jni rule and import pre-built libteec.so file with CMake option, it would work.
(If I made a CA using android ndk and run, it would interact with pre-built optee_example TA in my optee_os through client APIs. Please correct me if I’m wrong.)
But, though I build and install the application as a system app, it just repeated execution and dead forever when it is run.
Environment
- AndroidStudio
3.6.2
, kotlin1.3.71
and CMake3.10.2
(not using Android.mk file) on VMware ubuntu18.04
LTS - HiKey960 4GB RAM, AOSP+OP-TEE
3.4.2
branch, touchscreen enabled
First, I tried android ndktest project. I could make and run successfully.
Next, tried to build CA.
I referred to this issue
and could follow at this point with using CMake.
I could build apk, install and generate libincrement.so and libteec.so(pre-built arm64 cross-compiled) in /data/app/mypackage/lib/arm64/
but I couldn’t open my package with libc++.so.
This is logcat logs of my application.
2020-06-07 08:27:06.156 21255-21255/? W/main: type=1400 audit(0.0:9124): avc: denied { dac_read_search } for capability=2 scontext=u:r:zygote:s0 tcontext=u:r:zygote:s0 tclass=capability permissive=0
2020-06-07 08:27:06.405 21255-21255/com.example.retest D/AndroidRuntime: Shutting down VM
2020-06-07 08:27:06.407 21255-21255/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.retest, PID: 21255
java.lang.UnsatisfiedLinkError: dlopen failed: library “libc++.so” not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
at java.lang.System.loadLibrary(System.java:1669)
at com.example.retest.MainActivity.(MainActivity.kt:30)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69)
at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
at android.app.Instrumentation.newActivity(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2869)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2020-06-07 08:27:06.412 21255-21255/? I/Process: Sending signal. PID: 21255 SIG: 9
Though I installed as a system app, the application just repeated execution and dead forever. And I’m stuck in here.
This is my project tree under …/src/main/cpp/
* MainActivity capture
* increment.cpp capture
…
(totally same part with main.c)
…
This is my CMakeLists.txt file.
cmake_minimum_required(VERSION 3.4.1)
add_library(
teec
SHARED
IMPORTED
)set_target_properties(
teec
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/jniLibs/arm64-v8a/libteec.so
)include_directories(${CMAKE_SOURCE_DIR})
add_library(
increment
SHARED
increment.cpp
}find_library(
log-lib
log
)target_link_libraries(
increment
teec
${log-lib}
)
Repeated logcat logs
2020-06-07 09:33:36.540 23180-23180/? W/main: type=1400 audit(0.0:9436): avc: denied { dac_read_search } for capability=2 scontext=u:r:zygote:s0 tcontext=u:r:zygote:s0 tclass=capability permissive=0
2020-06-07 09:33:36.560 23180-23180/? I/.example.retes: Late-enabling -Xcheck:jni
2020-06-07 09:33:36.908 23180-23180/com.example.retest W/.example.retes: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
2020-06-07 09:33:36.908 23180-23180/com.example.retest W/.example.retes: Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)
2020-06-07 09:33:36.908 23180-23180/com.example.retest W/.example.retes: Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)
2020-06-07 09:33:36.908 23180-23180/com.example.retest W/.example.retes: Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)
2020-06-07 09:33:36.908 23180-23180/com.example.retest W/.example.retes: Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)
2020-06-07 09:33:36.946 23180-23180/com.example.retest W/.example.retes: Accessing hidden method Landroid/view/View;->getAccessibilityDelegate()Landroid/view/View$AccessibilityDelegate; (light greylist, linking)
2020-06-07 09:33:37.003 23180-23180/com.example.retest W/.example.retes: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
2020-06-07 09:33:37.004 23180-23180/com.example.retest W/.example.retes: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
2020-06-07 09:33:37.012 23180-23180/com.example.retest W/.example.retes: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking)
2020-06-07 09:33:37.041 23180-23180/com.example.retest D/test: testestestest
Please help me if you have any idea.