All Questions
Tagged with java-native-interface android-studio
246 questions
0
votes
0
answers
67
views
How to access global variables into java and native code while working on JNI
I am working on JNI as i converted all c code in JNI format now i want access for global variables ,macros,struct in both java and native file as i have all those variables in natives header file so i ...
1
vote
0
answers
131
views
Unable to run android app with prebuilt native library
I have a library written in c++, and it is pre built by Androi NDK clang++ with Makefile command, like this:
libfoo.so:
$(CXX) -c -Wall -Werror -fpic ${SRC_PATH}foo.cpp
$(CXX) -shared -o ...
1
vote
1
answer
302
views
How to suppress "Cannot resolve corresponding JNI function" in Android Studio?
I am creating a native method in Android Studio which is registered using RegisterNatives in JNI_OnLoad when the library is loaded. The problem is that I want to encrypt the method name and signature ...
0
votes
0
answers
504
views
Andorid jniLibs not getting packed in APK
I've two shared libraries libsample.so and libsycl.so.6 in jniLibs/arm64-v8a folder. Upon building and analyzing the apk, I could see only libsample.so got placed in APK's lib folder but not the ...
1
vote
1
answer
177
views
Android Studio - destroying when not connected to debugserver
So I've started to create an application with some native C++ code in Android Studio. My phone is Realme 8i.
I've deployed my app to this phone. Everything works great until I try to debug my app.
...
0
votes
1
answer
76
views
Do I have to create static attributes to update UI in JNI?
My Target
I'm coding an android studio project with some c++ code
I want to update UI within c++ code
My Code
The code is as follows:
MainActivity.java:
public class MainActivity extends ...
1
vote
1
answer
108
views
Why can only int be calculated in return when using ndk build?
I am trying to make a project using jni into aar. However, simple int calculation seems to be possible with return in the cpp part, but I don't know why an error occurs when I try to use the if ...
1
vote
1
answer
1k
views
Android: Trying to compile native code, getting UnsatisfiedLinkError: No implementation found
I am trying to fork AndroidPdfViewer to replace its underlying library from PdfiumAndroid to android-pdfium.
My problem is, when I load AndroidPdfViewer and PdfiumAndroid in Android Studio, I can't ...
1
vote
0
answers
916
views
How to use ndk-stack in Android Studio?
I need to debug my native C code. (I'm a newbie in C and ndk). I get this error, but i don't know exactly from where the bug come from:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x38
I ...
2
votes
1
answer
1k
views
Very slow debugging of native code in Android Studio
I put a breakpoint to my native code.
However when I attach the debugger, the app becomes inactive and it takes a while (10-15 minutes) until Android Studio stops at the breakpoint and allow me to do ...
0
votes
0
answers
68
views
How to send several data in JNI between C and Java
For my project, I need to get a buffer send by a Java application into my C application.
Now I'm having a simple int array in java, that i want to modify some of his data and return it.
In C It's ...
21
votes
4
answers
11k
views
Error:(1, 1) Unable to execute Clang-Tidy: clazy-standalone is not found or cannot be executed in AndroidStudio
In my AndroidStudio project I created native library using JNI with CMake and CPP code. Everything builds and runs OK, but when I try to commit and push my code to git, the CodeAnalysis appears in the ...
0
votes
0
answers
311
views
Debugging into native C++ code of Android platform/framework libraries
I have an Android app that uses classes from the Android framework/platform, for example AudioTrack. I'd like to find out more about how those classes work internally by stepping into the code of ...
0
votes
0
answers
146
views
Android Studio, Adding Native C++ Code via JNI to a Second Activity of an Android App
I'm using Android Studio to build an Android app. I'm using Kotlin, and I'm using C++ code, i.e. native C++ that I interface with using JNI. I'm able to do this in the MainActivity, because ...
0
votes
1
answer
793
views
Android Studio spurious "Cannot resolve corresponding JNI function"
Android Studio is showing this error. Here's a snippet of the relevant code:
public class MainActivity extends AppCompatActivity {
...
static native void runTests(String path);
static {
...
0
votes
0
answers
64
views
How to add a JNI C function, accessible as a java method, into my android application?
I want to know how to(from android-studio or by modifying the build files), add a C/C++ file with a function that shows up as a java accessible method.
1
vote
0
answers
588
views
.so file is not loading, when running the app on the virtual device
I used a physical machine to develop and try to load the .so file. I put all .so file under the "app/libs" folder and add the code at build.gradle
sourceSets {
main {
...
1
vote
1
answer
145
views
Can Android Studio 4 build projects with API < 9?
I would like my app to support any Android phone api 3 and above.
Why? Because I dislike waste and these older phones are perfectly good enough for the task at hand.
Sadly getting info about basic pre-...
1
vote
1
answer
829
views
QApplication on Android, started from JNI leads up to SEGFAULT
The main goal is to develop an .apk in Android Studio with qt based shared libraries (.so) onboard and start hidden qt event loop (QCoreApplication) in there.
The first of all,
I were concerned on ...
0
votes
1
answer
201
views
JNI getting error message after exiting conditinal loop when the method returns
I am new with c and i am trying to create this project in android studio that reads linux input with /dev/input/event* directory, the other part that read's so is an executable program (run with root ...
2
votes
2
answers
867
views
Android Studio can't debug if I use C code
Android Studio can't start the debugger if I use C code though JNI.
Running it normally works well, but the debugger doesn't even start, regardless if I'm debugging Kotlin or C code.
It throws a ...
1
vote
1
answer
550
views
Adding Java JNI -Xcheck:jni option to run command in Android Studio
Newbie question: my app is crashing when it enters my JNI wrapper, and I have read that the Java -Xcheck:jni flag will help to find some coding errors. I don't know how to pass the flag to the run ...
0
votes
0
answers
101
views
Native Android java methods not finding any reference
I have Two Modules first have Jni Android.MK file and the second have CMakeList.txt
the first module has dependencies of the second module.
Now when I call any native java method from First Module it ...
1
vote
0
answers
421
views
How to build the LAPACK in Android Studio
Currently, I have an Android Project in which I am using the JNI(Java native interface) to call the LAPACK C function.
My JNI is:
native-lib.c
#include <jni.h>
#include "lapack/LAPACKE/...
0
votes
0
answers
855
views
File Not Found at /storage/emulated/0, Android Studio
I am creating an android application for image captioning and have used caffe_jni for it but I'm getting an error:
F0315 Check failed: fd!= -1 (-1 vs. -1) File not found: /storage/emulated/0/...
3
votes
1
answer
715
views
Missing step to create a new AS project and get a lib folder populated on my device upon installation
Goal
I want the libs present in my APK to be available on my device from a fixed location when I install my APK.
I opened another question about this issue based on my existing project. This time, I ...
10
votes
0
answers
2k
views
Understanding "JNI Critical Lock held " log
What is the meaning of logs.(there are lot of similar logs)
W/SomeModule: JNI critical lock held for 29.208ms on Thread[22,tid=14865,Runnable,Thread*=0xd5d80800,peer=0x130012b8,"main-some-thread-...
2
votes
1
answer
324
views
How to step into native code with disassembling in Android Studio?
I am trying to step into(F7) a native function in Android Studio, but it steps over. I want to step into the native function by LLDB, and disassembling the function.
How to step into a native library(...
0
votes
1
answer
1k
views
Debugging C++/Native code in Android Studio doesn't work with older Android SDK API version
General problem
I have an Android Native application that targets two different API versions: 23 (Marshmallow) and 28 (Pie). For the API 28, I have no problem debugging a hello world application when ...
6
votes
1
answer
5k
views
Specify targets in externalNativeBuild of the build.gradle file-> No signature of method
Start a new native c++ project in android studio 4.1.1.
Go to build.gradle of the module
Add a targets line:
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists....
0
votes
0
answers
197
views
Stuck on weird crash when calling GetFieldID for recovering member id of custom java class in jni
Here is a custom java class:
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.PointF;
import android.graphics.Rect;
public class ...
1
vote
1
answer
124
views
Embed C library in Java library
I have a Java library for Android which I distribute to third party developers, and I want to embed a C library in it. I've added the library to the project via CMake:
add_library(wrapper SHARED wrap....
0
votes
0
answers
468
views
Passing an array back and forth from Java to C in JNI
I'm working on an Android Studio project that involves JNI to run some signal processing functions on arrays created in Java. I need to be able to feed C an array of double from Java, run the filter, ...
0
votes
0
answers
60
views
How to generate bundle with native code with Android Studio correctly?
I am trying to publish an Android application with Android Studio's Generate Signed Bundle or APK (choosing bundle) feature.
At first, I was getting native crashes and was trying to investigate them. ...
0
votes
1
answer
292
views
JNI native method missing but no build error
In MyClass.java I have
package com.example.foo;
public class MyClass {
public native void MyMethod();
and in MyClass.cpp I have
JNIEXPORT void JNICALL xJava_com_example_foo_MyClass_MyMethod(...
1
vote
1
answer
1k
views
JNI "undefined reference" to c++ method
I'm trying to create poker app with JNI in android studio, I want to save one instance of c++ class (TexasHoldem) and invoke it's methods only.
in the texasJNI.java I wrote:
public class ...
0
votes
1
answer
227
views
Is it possible to create a NewGlobalRef from a Class in last Android versions?
I have import and tested this project:
https://github.com/android/ndk-samples/tree/master/hello-jni
in Android Studio and worked well.
But when I copy the code for another new project I have ...
0
votes
0
answers
272
views
I get java.lang.UnsatisfiedLinkError when try to call a native function from my project configured with bazel
I have created a cc_library in my bazel Build file and added the deps in android_binary rule
Bazel BUILD:
cc_library(
name = "native_libs",
srcs = glob([
"app/src/main/jni/**/*.cc",
...
1
vote
1
answer
458
views
Is it sufficient to load the Native library at only one activity while we need to use it inside whole Android app?
I want to use Native JNI library inside my android project. But I've a question, like I want to use this library methods inside around 10 activities of my app. So should I load the library to every ...
1
vote
1
answer
1k
views
Trying to call function from JNI, but I get No implementation found
I'm trying to call a native function using ndk/jni but I get this exception
java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String
com.raya.aman.ToolModule.stringFromJNI() (...
0
votes
1
answer
703
views
trying to use android NDK/JNI but i get exception UnsatisfiedLinkError: dlopen failed
i am trying to use android ndk/jni but i get this exception when ever i call stringFromJNI();
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.raya.aman-
A_B2z5nEzTvL2uOtrxLexQ==/lib/...
1
vote
0
answers
176
views
Android Cross Compilation JNI -> No implementation found for
I am using a shared library libToon-c.so in my android app.
When running this app via the Android Virtual Device (AVD), the shared library is loaded and running without any problems.
However when ...
0
votes
1
answer
56
views
Include .so file in android project
I want to include .so file in the android project and want to call methods in java from within the
c++ source code. I have included the .so file in jniLibs folder of android project. Can anyone tell ...
0
votes
0
answers
77
views
Call an method in jni
Hi i have the following problem in my android studio
root.cpp:
int getRoot(char *argv[])
{
char ml[64];
sprintf(ml,"su -c %s",*argv);
if (getuid() != 0)
{
system(ml);
...
2
votes
1
answer
613
views
How to import a .cpp C++ native library into Android Studio
I have a .cpp file that is a native library (called "native-lib.cpp") I would like to import into a project in Android Studio so that I can access it by running
System.loadLibrary("native-lib");
I ...
0
votes
2
answers
436
views
Calling 3rd party native library in your own android app
Is it possible to write code for native libraries you do not have the source code for in your own android app?
For example - RarLab's android app comes with a native library librarlab_rar.so for at ...
0
votes
1
answer
322
views
How to add already compiled C code to android studio project?
After having already checked this 1 and 2 and several more I could not find an answer so...
I am trying to find a way to include some C code I have into an Android Project but without having to give ...
2
votes
0
answers
309
views
Debug so file in Android Studio 3
I have a project that by historical reasons I can compile only on VS + old NDK.
The result is an so file which originally then was wrapped into an apk, so there is no way to debug it in VS.
I have ...
4
votes
2
answers
2k
views
In JNI function when I change an Array in-place that was passed from Java code the Array doesn't modify
I'm passing an int array from Java to native method.
Then within JNI function I created a pointer to int array with GetIntArrayElements() and pass as *isCopy argument JNI_FALSE. I supposed that this ...
3
votes
1
answer
2k
views
Error building : depfile has multiple output paths ninja: build stopped: subcommand failed
I got this error while building a Java project with JNI code that needs CMake support. This project is built with Android Studio, with the support of NDK, CMake and LLVM. These are the flags below ...