java-native-interface

How to call JNI Function from a method in C library

牧云@^-^@ 提交于 2021-02-10 12:54:09
问题 I'm currently developping an android app with android studio, for this project i need to use a custom library written in c/c++ . So i in order to do that i needed to use NDK. The library contain methods that i need to implements in order to have access to specifics fonctions in android My question is : how can I call my jni method inside the method existing in c which will call a java method to store session key in the android system So for a pratical exemple since it's maybe not clear: In a

C++ Multithread Java JNI method Call

筅森魡賤 提交于 2021-02-08 19:55:18
问题 I have a simple class in Java: public class MyClass { public static void dummyTest() { } } And in C++ I do the following JNI Call: void c_call_function() { JNIEnv *env ...// the JNIEnv initialization in JNI... jclass clazz ...// the class initialization in JNI... jmethodID mid_dummyTest = env->GetStaticMethodID(clazz, "dummyTest", "()V"); env->CallStaticIntMethod(clazz, mid_dummyTest); } If a single program calls the static method c_call_function() it is ok. But if a multithread program calls

How to use .so in a second project in Android?

喜你入骨 提交于 2021-02-08 10:30:34
问题 I am doing an app in Android which uses native code with JNI and I have a question for you. I built some code in c++ to create .so library. then i use this .so in my project and in my Nexus 5 works fine but when I try in other devices app crashes. I did a lot of test and fail is caused by use this .so in my project, but i don't know because in nexus 5 is Ok and in other devices no. This is my Android.mk: LOCAL_PATH := $(call my-dir) # Create `DSP-prebuilt` local prebuilt library from `DSP.so`

How to use .so in a second project in Android?

依然范特西╮ 提交于 2021-02-08 10:30:14
问题 I am doing an app in Android which uses native code with JNI and I have a question for you. I built some code in c++ to create .so library. then i use this .so in my project and in my Nexus 5 works fine but when I try in other devices app crashes. I did a lot of test and fail is caused by use this .so in my project, but i don't know because in nexus 5 is Ok and in other devices no. This is my Android.mk: LOCAL_PATH := $(call my-dir) # Create `DSP-prebuilt` local prebuilt library from `DSP.so`

Android NDK: libc++ support for hard-float

余生颓废 提交于 2021-02-08 07:58:29
问题 I am running into problems when compiling a small Java program that uses several custom c++ libraries. All the libraries are targeting armeabi-v7a and are compiled with hard-float support (mfloat-abi=hard -mfpu=neon -mhard-float -D_NDK_MATH_NO_SOFTFP=1). I have couple of other cpp files that are part of the Java/Android project; those are also compiled with the above settings and I link against libm_hard.a (instead of libm.a) When I run the program, I am getting strange behavior with floats

Android Studio | CPP file errors error: undefined reference to 'AndroidBitmap_unlockPixels' In bitmap library

我的未来我决定 提交于 2021-02-08 07:36:13
问题 I'm trying to use AndroidJniBitmapOperations library. But I'm a Junior Dev, with no knowledge in the NDK, JNI world. I succeed to resolve a few errors like 'UnsatisfiedLinkError', but Now I'm getting a new one when I trying to build: error: undefined reference to 'AndroidBitmap_unlockPixels' Also I get a few errors inside the CPP file: 1."Incorrect type for parameter 'prarmeterName', which should have type 'jint'. 2."Add extern 'C'" But I don't sure if the last 2 are important. Help me to

Android Studio | CPP file errors error: undefined reference to 'AndroidBitmap_unlockPixels' In bitmap library

♀尐吖头ヾ 提交于 2021-02-08 07:33:32
问题 I'm trying to use AndroidJniBitmapOperations library. But I'm a Junior Dev, with no knowledge in the NDK, JNI world. I succeed to resolve a few errors like 'UnsatisfiedLinkError', but Now I'm getting a new one when I trying to build: error: undefined reference to 'AndroidBitmap_unlockPixels' Also I get a few errors inside the CPP file: 1."Incorrect type for parameter 'prarmeterName', which should have type 'jint'. 2."Add extern 'C'" But I don't sure if the last 2 are important. Help me to

Show Toast in Android by sending string from c++ JNI in qt

会有一股神秘感。 提交于 2021-02-07 21:13:57
问题 I am trying display a toast on the Java method call from C++ side I have managed to call that method and even getting string but Toast is not working I have tried almost everything with context and all C++ Side JavaVMAttachArgs args = { JNI_VERSION_1_6, NULL, NULL }; vm->AttachCurrentThread( &env, &args ); activityConstructor = env->GetMethodID(activity, "<init>", "()V"); jobject object = env->NewObject(activity, activityConstructor); toastID = env->GetMethodID(activity, "toast", "(Ljava/lang

QT/QML Android App, open app when click notification bar

我怕爱的太早我们不能终老 提交于 2021-02-07 14:17:47
问题 I make an QT for Android apps. When I click button notify bar seen above in tablet. But if click notify, my apps open/focus(don' know) with black window. How to do it simply. My code is: package org.ays.operation; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.app.PendingIntent; import android.content.Intent; public class NotificationClient extends org.qtproject.qt5.android.bindings.QtActivity { private static

Reproducing and resolving Android java.lang.unsatisfiedLinkError locally

你离开我真会死。 提交于 2021-02-07 11:13:44
问题 Together with a friend I have created an Android app to organize school grades. The app works fine on my device and on most user devices, however there is a crashing rate over 3 percent, mostly because of java.lang.UnsatisfiedLinkError and occurring on Android versions 7.0, 8.1 as well as 9. I've tested the app on my phone and on several emulators, including all the architectures. I upload the app to the app store as an android-app-bundle and suspect that this could be the source of the