Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – using your own Makefiles with Gradle


Using your own handmade makefiles with Gradle is a bit tricky but not too complicated:

  1. Copy the Android.mk and Application.mk files we created in the Interfacing Java with C/C++ section in this chapter into the app/src/main/jni directory.

  2. Edit app/build.gradle.

  3. Add an import for the OS "Class" and remove the first ndk section we created in the previous section:

    import org.apache.tools.ant.taskdefs.condition.Os
    
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"
    
        defaultConfig {
            applicationId "com.packtpub.store"
            minSdkVersion 14
            targetSdkVersion 21
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
  4. Still in the android section of app/build.gradle., insert a sourceSets.main section...