【发布时间】:2019-10-31 14:00:59
【问题描述】:
我使用 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)
build.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'
}
谢谢
【问题讨论】:
-
您使用的是哪个 NDK 版本?据说双簧管适用于 NDK r17 及更高版本。
-Werror由 Oboe 在调试版本中设置。 -
作为一种解决方法,您可以从
CMakeLists.txtgithub.com/google/oboe/blob/master/CMakeLists.txt#L77 中删除-Wshadow-field
标签: android android-studio android-ndk c++14 oboe