Search code examples
androidandroid-studioandroid-ndkc++14oboe

unknown warning option '-Wshadow-field' error using Oboe on android studio


I've created a ndk project using android studio and every think goes fine and I can launch my app on emulator without any problem. But when I add Oboe library to my project this error comes up when I try to launch or build my app. I'm using c++14 for this app. I think there is some problem with clang but I dont have any Idea how to solve it.

Here is the error log, Cmake file and build.gradle file:

error log:

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'
}

Thanks


Solution

  • Thank you @Michael. The problem was from NDK version. but if any one face this problem be sure to have the latest andriod studio version and the latest gradle version. because its needed.