fatal error: string: No such file or directory - Android Studio

fatal error: string: No such file or directory - Android Studio

所以我只是将 eclipse 上的一个 Android 项目导入到一个 Android Studio 中,用 ndk C++ 来构建,当我尝试构建时我遇到了一个错误:(在 win7 64x 上javajdk1.8.0_40和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"

在我的 file1.h 我有一个

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

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

[...]

我仔细检查,我包含的 file2.h 路径是好的,我的其他路径没有错误,例如 filexxx.h.

在此之前,我只是将 ndk 路径添加到我的 local.properties :

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

我的Application.mk就是这样:

APP_STL :=stlport_static

APP_ABI:= armeabi-v7a

APP_CPPFLAGS += -fexceptions

还有我的Android.mk

LOCAL_PATH:=$(call my-dir)

include $(CLEAR_VARS)

all my files .cpp

[...]

include $(BUILD_SHARED_LIBRARY)

我是否缺少在 android studio 上做的事情以使其正常工作?需要帮助,谢谢。

好的,我找到了解决方案,我会在这里解释一下,这很有用。我遵循了本教程:http://visualgdb.com/tutorials/android/astudio/

而且我注意到它说JNI文件夹必须在app文件夹下。我的是通过 android studio conversion 自动放置在 src 文件夹下的!

尝试将 stl "stlport_static" 添加到模型 build.gradle 中的 ndk 部分,如下所示:

    ndk {
            moduleName "MyModel"
            stl "stlport_static"
    }
    
如果你使用 Gradle 2.5,它应该是这样的:
    android.ndk {
            moduleName = "MyModel"
            stl = "stlport_static"
     }