1

我已经使用 android studio 创建了一个 ndk 项目,每个想法都很好,我可以在模拟器上启动我的应用程序而没有任何问题。但是当我将双簧管库添加到我的项目时,当我尝试启动或构建我的应用程序时会出现此错误。我正在为这个应用程序使用 c++14。我认为clang有一些问题,但我不知道如何解决它。

这是错误日志、Cmake 文件和 build.gradle 文件:

错误日志:

Information:Gradle tasks [:app:assembleDebug]
Error:unknown warning option '-Wshadow-field' [-Werror,-Wunknown-warning-option]
Error:unknown warning option '-Wshadow-field' [-Werror,-Wunknown-warn
Error:unknown warning option '-Wshadow-field' [-Werror,-Wunknown-warning-option]
Information:BUILD FAILED in 1s
Information:3 errors
Information:0 warnings
Information:See complete output in console

CMakeLists.txt:

cmake_minimum_required(VERSION 3.4.1)
add_library( 
             native-lib
             SHARED
             src/main/cpp/native-lib.cpp )

find_library( 
              log-lib

              log )

target_link_libraries(
                       native-lib

                       ${log-lib} )

#set the path to the oboe directory
set (OBOE_DIR /home/user/AndroidProjects/oboe)

#add the Oboe library as a subdirectory in project
add_subdirectory (${OBOE_DIR} ./oboe)

#Specify the path to the Oboe header files
include_directories (${OBOE_DIR}/include)

#Specify the libraries which are native library is dependent on, including Oboe
target_link_libraries (native-lib log oboe)

构建.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.app.audiovisualizera"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++14"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

谢谢

4

1 回答 1

1

谢谢@迈克尔。问题来自NDK版本。但如果有人遇到这个问题,一定要拥有最新的 andriod studio 版本和最新的 gradle 版本。因为它需要。

于 2019-11-01T18:00:29.503 回答