Android Studio gradle构建ndk错误

时间:2015-01-21 10:12:12

标签: android gradle android-ndk

我想在android中使用c ++ STL,但是当我包含STL(例如:hash_map)时,则运行该错误。

我使用android studio 1.0.2和android ndk r10d

这是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.ndktest"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"

        ndk {
            moduleName 'JNI'
            stl 'stlport_shared'
        }

    }
    productFlavors {
        arm {
            ndk {
                abiFilters "armeabi", "armeabi-v7a"
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

错误讯息:

警告[Project :: app]不推荐使用当前的NDK支持。将来会提供替代方案。 警告[Project :: app]不推荐使用当前的NDK支持。将来会提供替代方案。 :应用程序:预生成 :应用:compileArmDebugNdk 在C包含的文件中:/Users/Sheng/Developer/android/SDK_Libs/android-ndk/sources/cxx-stl/stlport/stlport/stl/_algobase.h:46:0,                  来自C:/Users/Sheng/Developer/android/SDK_Libs/android-ndk/sources/cxx-stl/stlport/stlport/stl/_vector.h:34,                  来自C:/Users/Sheng/Developer/android/SDK_Libs/android-ndk/sources/cxx-stl/stlport/stlport/stl/_hashtable.h:34,                  来自C:/Users/Sheng/Developer/android/SDK_Libs/android-ndk/sources/cxx-stl/stlport/stlport/stl/_hash_map.h:34,                  来自C:/ Users / Sheng / Developer / android / SDK_Libs / android-ndk / sources / cxx-stl / stlport / stlport / hash_map:38,                  来自C:\ Users \ Sheng \ tmp \ NDKTEST \ app \ src \ main \ jni \ maps.h:5,                  从C:\ Users \ Sheng \ tmp \ NDKTEST \ app \ src \ main \ jni \ maps.cpp:1: C:/Users/Sheng/Developer/android/SDK_Libs/android-ndk/sources/cxx-stl/stlport/stlport/stl/_cstdlib.h:在函数' long int abs(long int)' : C:/Users/Sheng/Developer/android/SDK_Libs/android-ndk/sources/cxx-stl/stlport/stlport/stl/_cstdlib.h:131:25:错误:C函数声明' long int abs (long int)'与...发生冲突  内联长abs(长__x){return _STLP_VENDOR_CSTD :: labs(__ x); }                          ^ 更...

我该如何解决? 感谢。

0 个答案:

没有答案