5

I created an Android project with default C++ toolchain. Now when I was trying to include code snippets from sample projects on oboe containing C++14 features I keep on getting errors. So I tried included code to create a template but now it is making my code messy and dumped with the declarations which I will prefer not to have.

I tried referring to following questions.

  1. Enable C++11 support on Android

  2. How to Compile C++14 code for Android?

But all these answers seem outdated or I am missing something. There is no Android.mk file in my project structure neither I can find settings that they are suggesting to change.

I suspect the Android studio interface was changed after posting these answers. So what is the right way to change C++ toolchain version in Android Studio 3+?

Mandar Sadye
  • 689
  • 2
  • 9
  • 30

1 Answers1

6

You specify it in your app/build.gradle script.

android {
    defaultConfig {
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++14"
            }
        }
    }
}

Change cmake to ndkBuild depending on which method you're using.

Michael
  • 57,169
  • 9
  • 80
  • 125