2
votes

So I just import an Android project on eclipse to an Android Studio one with ndk C++ to build, and when I try to build I've got an error : (On win7 64x java jdk1.8.0_40 and ndk 10)

AGPBI: {"kind":"SIMPLE","text":"In file included from C:\Users\Myname\AndroidStudioProjects\Myproject\app\src\main\jni\path\to\my\file1.h

[...]

AGPBI: {"kind":"SIMPLE","text":"C:\Users\Myname\AndroidStudioProjects\Myproject\app\src\main\jni\path\to\my\file2.h:28:18: fatal error: string: No such file or directory"

In my file1.h I've got an

#include "path/to/my/filexxx.h"

#include "path/to/my/file2.h"

[...]

I double check, my included path to file2.h is good, there is no error for my others includes like filexxx.h.

Before that I just add the ndk path to my local.properties :

ndk.dir=C:\Users\path\to\android-ndk-r10d

My Application.mk is like that :

APP_STL :=stlport_static

APP_ABI:= armeabi-v7a

APP_CPPFLAGS += -fexceptions

And my Android.mk

LOCAL_PATH:=$(call my-dir)

include $(CLEAR_VARS)

all my files .cpp

[...]

include $(BUILD_SHARED_LIBRARY)

Am I missing something to do on android studio to make it works ? Help needed, thanks.

2
In file2.h do you have #include <string>?NathanOliver
No I didn't have it, I just add it but no change in the build and the error displayed.Brian

2 Answers

3
votes

Try to add stl "stlport_static" to your ndk section in the model build.gradle as following:

    ndk {
            moduleName "MyModel"
            stl "stlport_static"
    }
    
    android.ndk {
            moduleName = "MyModel"
            stl = "stlport_static"
     }
1
votes

Ok I found the solution, I will explain it here, that can be useful. I followed this tutorial : http://visualgdb.com/tutorials/android/astudio/

And I noticed that it said that the JNI folder must be under the app folder. Mine was automaticaly placed by android studio conversion under the src folder !