9

I would like to include c++ header iostream into my NDK code. In order to do that, I have to include APP_STL := stlport_static (or similar) into Application.mk file as mentioned in Android ndk-build iostream: No such file or directory.

It all works well if I compile using command line ndk-build, however while compiling using Android Studio, I still get the same error as iostream not found. It looks like application.mk is ignored by Android Studio and I am not sure how to configure it in build.gradle. Can anyone help me including APP_STL := stlport_static using android studio?

Thanks

Community
  • 1
  • 1
Androidme
  • 3,145
  • 3
  • 24
  • 27

3 Answers3

5

It looks like at the moment there is no support for including Application.mk file in build.gradle, however adding stl "stlport_static" under ndk section of build.gradle works well (thanks Michael for quick reply).

Under defaultConfig section, add:

    ndk {
        moduleName "app"
        stl "stlport_static"
    }

Details can be found at: https://groups.google.com/forum/#!topic/adt-dev/pHnST37HrlM

Androidme
  • 3,145
  • 3
  • 24
  • 27
  • 1
    You can include Application.mk and compile only one command line and include jni.srcDirs = [] //disable automatic ndk-build call in your build.gradle to ignore automatic build by Android Studio – G3M Jan 14 '15 at 21:45
3

For Gradle 2.5, it should look like this:


    android.ndk {
        moduleName = "app"
        stl = "stlport_static"
    }

Key
  • 139
  • 1
  • 9
1

For Gradle 4.4 : Adding

path 'jni/Application.mk'

to the app level build.gradle solved my problem. It should be like this

externalNativeBuild {
    ndkBuild {
        path 'jni/Android.mk'
        path 'jni/Application.mk'
    }
}

Then Android Studio checks for your Application.mk file.

My folder structure is like this

Fatih
  • 1,304
  • 1
  • 11
  • 10