Android ndk Android studio build ndk项目找不到“;“字符串”;文件

Android ndk Android studio build ndk项目找不到“;“字符串”;文件,android-ndk,Android Ndk,我的ndk演示已经正确运行了。但当我包含和其他一些文件时,就会抛出构建错误 build.gradle: ndk { moduleName "addcomputer" abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86','x86_64' // <- only the supported ones } task ndkBuild(type:Exec,description:'Compile JNI sourc

我的ndk演示已经正确运行了。但当我包含和其他一些文件时,就会抛出构建错误

build.gradle:

ndk {
        moduleName "addcomputer"
        abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86','x86_64' // <- only the supported ones
    }
    task ndkBuild(type:Exec,description:'Compile JNI source via NDK'){
        commandLine "/Users/eilir/Downloads/android-ndk-r16-beta1/ndk-build",
                'NDK_PROJECT_PATH=build/intermediates/ndk',
                'NDK_LIBS_OUT=src/main/jniLibs',
                'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
                'NDK_APPLOCATION_MK=src/main/jni/Application.mk',
                "V=1",
                "APP_STL=stlport_shared",
                "APP_CPPFLAGS = -fexceptions"
    }......
Application.mk内容:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := addcomputer
LOCAL_SRC_FILES := addcomputer.cpp
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
APP_ABI:=armeabi-v7a, arm64-v8a, x86, x86_64
#指定C++运行库为微型系统C++运行库
#APP_STL:=stlport_shared
APP_STL:=gnustl_shared
#APP_STL:=gnustl_static
#APP_STL:=system
#要为整个应用启用异常处理支持
APP_CPPFLAGS += -fexceptions
我的gradle构建命令行:

    /path/to/myndk/android-ndk-r16-beta1/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -MMD -MP -MF build/intermediates/ndk/obj/local/arm64-v8a/objs/addcomputer/addcomputer.o.d -gcc-toolchain /path/to/myndk/android-ndk-r16-beta1/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 -target aarch64-none-linux-android -ffunction-sections -funwind-tables -fstack-protector-strong -fpic -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes  -g -fno-exceptions -fno-rtti -O2 -DNDEBUG  -I/path/to/myndk/android-ndk-r16-beta1/sources/cxx-stl/stlport/stlport -I/path/to/myndk/android-ndk-r16-beta1/sources/cxx-stl//gabi++/include -Isrc/main/jni   -fexceptions  -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security  -frtti  --sysroot /path/to/myndk/android-ndk-r16-beta1/sysroot -isystem /path/to/myndk/android-ndk-r16-beta1/sysroot/usr/include/aarch64-linux-android -c  src/main/jni/addcomputer.cpp -o build/intermediates/ndk/obj/local/arm64-v8a/objs/addcomputer/addcomputer.o
我发现我的Application.mk可以在build.gradle中重写,但即使我配置APP_STL=stlport_shared,我也可以在路径“/path/to/myndk/android-ndk-r16-beta1/sources/cxx STL/stlport/stlport”中找到“string”文件,我不明白为什么编译器找不到“string”文件。有人能帮我吗

超加: 我刚刚发现gradle的任务是多种多样的。如下所示:

:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:generateDebugAndroidTestResValues
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:incrementalDebugJavaCompilationSafeguard
:app:javaPreCompileDebug
:app:ndkBuild
        :app:compileDebugNdk
Warning: Deprecated NDK integration enabled by useDeprecatedNdk flag in gradle.properties will be removed from Android Gradle plugin soon.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
 https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
 https://developer.android.com/studio/build/experimental-plugin.html.

Android NDK: WARNING: Unsupported source file extensions in /path/to/project/app/build/intermediates/ndk/debug/Android.mk for module addcomputer    
Android NDK:   /path/to/project/app/src/main/jni/Android.mk /path/to/project/app/src/main/jni/Application.mk    
Android NDK: WARNING: Unsupported source file extensions in /path/to/project/app/build/intermediates/ndk/debug/Android.mk for module addcomputer    
Android NDK:   /path/to/project/app/src/main/jni/Android.mk /path/to/project/app/src/main/jni/Application.mk    
Android NDK: WARNING: Unsupported source file extensions in /path/to/project/app/build/intermediates/ndk/debug/Android.mk for module addcomputer    
Android NDK:   /path/to/project/app/src/main/jni/Android.mk /path/to/project/app/src/main/jni/Application.mk    
Android NDK: WARNING: Unsupported source file extensions in /path/to/project/app/build/intermediates/ndk/debug/Android.mk for module addcomputer    
Android NDK:   /path/to/project/app/src/main/jni/Android.mk /path/to/project/app/src/main/jni/Application.mk    
[armeabi-v7a] Compile++ thumb: addcomputer <= addcomputer.cpp
[armeabi-v7a] Compile++ thumb: addcomputer <= Socket.cpp


/path/to/project/app/src/main/jni/Socket.cpp:9:10: fatal error: 'iostream.h' file not found
#include <iostream.h>
         ^~~~~~~~~~~~
1 error generated.


:app:compileDebugNdk FAILED 
查看上面的最后一行::app:ndkBuild,该任务运行良好,错误发生在其他任务中,如下所示:

:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:generateDebugAndroidTestResValues
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:incrementalDebugJavaCompilationSafeguard
:app:javaPreCompileDebug
:app:ndkBuild
        :app:compileDebugNdk
Warning: Deprecated NDK integration enabled by useDeprecatedNdk flag in gradle.properties will be removed from Android Gradle plugin soon.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
 https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
 https://developer.android.com/studio/build/experimental-plugin.html.

Android NDK: WARNING: Unsupported source file extensions in /path/to/project/app/build/intermediates/ndk/debug/Android.mk for module addcomputer    
Android NDK:   /path/to/project/app/src/main/jni/Android.mk /path/to/project/app/src/main/jni/Application.mk    
Android NDK: WARNING: Unsupported source file extensions in /path/to/project/app/build/intermediates/ndk/debug/Android.mk for module addcomputer    
Android NDK:   /path/to/project/app/src/main/jni/Android.mk /path/to/project/app/src/main/jni/Application.mk    
Android NDK: WARNING: Unsupported source file extensions in /path/to/project/app/build/intermediates/ndk/debug/Android.mk for module addcomputer    
Android NDK:   /path/to/project/app/src/main/jni/Android.mk /path/to/project/app/src/main/jni/Application.mk    
Android NDK: WARNING: Unsupported source file extensions in /path/to/project/app/build/intermediates/ndk/debug/Android.mk for module addcomputer    
Android NDK:   /path/to/project/app/src/main/jni/Android.mk /path/to/project/app/src/main/jni/Application.mk    
[armeabi-v7a] Compile++ thumb: addcomputer <= addcomputer.cpp
[armeabi-v7a] Compile++ thumb: addcomputer <= Socket.cpp


/path/to/project/app/src/main/jni/Socket.cpp:9:10: fatal error: 'iostream.h' file not found
#include <iostream.h>
         ^~~~~~~~~~~~
1 error generated.


:app:compileDebugNdk FAILED 
:app:compiledBugndk
警告:由gradle.properties中的UseDeprecatedNDDK标志启用的已弃用NDK集成将很快从Android gradle插件中删除。
考虑使用CGORD或NDK构建与稳定的Android GADLE插件的集成:
https://developer.android.com/studio/projects/add-native-code.html
或者使用实验插件:
https://developer.android.com/studio/build/experimental-plugin.html.
Android NDK:警告:模块addcomputer的/path/to/project/app/build/intermediates/NDK/debug/Android.mk中的源文件扩展名不受支持
Android NDK:/path/to/project/app/src/main/jni/Android.mk/path/to/project/app/src/main/jni/Application.mk
Android NDK:警告:模块addcomputer的/path/to/project/app/build/intermediates/NDK/debug/Android.mk中的源文件扩展名不受支持
Android NDK:/path/to/project/app/src/main/jni/Android.mk/path/to/project/app/src/main/jni/Application.mk
Android NDK:警告:模块addcomputer的/path/to/project/app/build/intermediates/NDK/debug/Android.mk中的源文件扩展名不受支持
Android NDK:/path/to/project/app/src/main/jni/Android.mk/path/to/project/app/src/main/jni/Application.mk
Android NDK:警告:模块addcomputer的/path/to/project/app/build/intermediates/NDK/debug/Android.mk中的源文件扩展名不受支持
Android NDK:/path/to/project/app/src/main/jni/Android.mk/path/to/project/app/src/main/jni/Application.mk

[armeabi-v7a]Compile++thumb:addcomputer我已经将IDE更新到Android studio 3.1.2和gradle版本4.4,并将ndk guild更改为CMake,将Android.mk和Application.mk更改为CMakeLists.txt,在几个小时的工作后,我终于得到了正确的状态。找不到错误“string”文件。现在一切正常。谢谢大家

为什么gradle脚本中有一个“APP\u STL=stlport\u shared”
?只需删除该选项。现在我发现该错误不是因为ndkbuild。我的编译器没有问题。错误发生在CompiledBugNDK进程中。它是
,而不是
。两种方法都尝试过,但都没有任何帮助。您为什么要使用过时的NDK集成方法,而不是在中描述的方法?(如果在Android工作室中用C++支持创建新项目,则默认为AfAIK)。