Nikhil Sharma
Nikhil Sharma

Reputation: 603

NDK build error in Android Studio for some C++ code

I am new to NDK, so I am getting an 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 C++ 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");

File android.mk

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)

File Application.mk

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16

File 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());
    }
}

How can I fix this error? Where am I doing a mistake?

Upvotes: 8

Views: 2874

Answers (3)

Donix Technologies
Donix Technologies

Reputation: 1

I have also been facing the same problem regarding NDK in my project as I have imported downloaded project.

I was stuck for a week to solve the problem. Then I have created a new project and added library and all files to this new one project and build the project.

And I successfully built my project.

Upvotes: 0

Abubakar
Abubakar

Reputation: 364

I have already faced this problem and there isn't any issue in your code, so check out these points:

  1. go to your project and check if it creates jnilibs or whatever you named it in your Gradle NDK_LIBS_OUT

  2. check your task ndkBuild in your app Gradle file and its location

  3. clean your project and build it again if it does not have created it yet

Upvotes: 1

Martin
Martin

Reputation: 768

Try deleting E:\startUpCode\OpenCvDemo\NDKTest\app\build\intermediates manually. Then try building again.

Upvotes: 4

Related Questions