I am new to NDK so i am getting error while building the project below :
Error:Execution failed for task ':app:transformNativeLibsWithStripDebugSymbolForDebug'.
java.io.IOException: Failed to delete E:\startUpCode\OpenCvDemo\NDKTest\app\build\intermediates\transforms\stripDebugSymbol\debug\folders\2000\1f\main\lib\mips
this is my cpp code
#include <com_nickworld_ndktest_NativeClass.h>
JNIEXPORT jstring JNICALL Java_com_nickworld_ndktest_NativeClass_getMessageFromJNI
(JNIEnv *env, jclass obj){
return env->NewStringUTF("This is the message from JNI");
android.mk file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := com_nickworld_ndktest_NativeClass.cpp
LOCAL_LDLIBS += -llog
LOCAL_MODULE := MyLib
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
MainActivity.java
public class MainActivity extends AppCompatActivity {
static {
System.loadLibrary("MyLibs");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
((TextView) findViewById(R.id.txtView)).setText(NativeClass.getMessageFromJNI());
}
}
I need help to fix this error and i am not getting where i am doing mistake. Thanks
To compile and debug native code for your app, you need the following components: The Android Native Development Kit (NDK): a set of tools that allows you to use C and C++ code with Android. CMake: an external build tool that works alongside Gradle to build your native library.
I did research and learned this: https://stackoverflow.com/a/59275504 Apparently "NDK (side by side)" means in new Android Studio you can download multiple NDK versions at once, and this means you are now required to tell Gradle which NDK to use or it won't know which one to pick.
Android provides Native Development Kit (NDK) to support native development in C/C++, besides the Android Software Development Kit (Android SDK) which supports Java. [TODO] more.
Try deleting E:\startUpCode\OpenCvDemo\NDKTest\app\build\intermediates
manually. Then try building again.
i have already face this problem and there is no issue in your code so check out this point
check your task ndkBuild in your app gradle file and its location
clean your project and build it again if it does not have created yet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With