The other option is to keep the source files in the structure that Android.mk prefers and create a build.gradle that maps the appropriate directories using source sets.

This was a common technique in the early days of migrating ADT-based projects to the Gradle build system before Android Studio came with an importer that moved all the files around automatically for you. Since then, using the sourceSets attribute has become somewhat of a lost art amongst Android folks.

In this case, the source tree would look like the following:

PlatformAppPackage/ aidl/ assets/ AndroidManifest.xml Android.mk build.gradle java/ jni/ res/

Awesome! We only had to add one file! Let’s see what it looks like:

build.gradle //Top-level buildscript information buildscript { repositories { mavenCentral () } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' } } //App module build information apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { targetSdkVersion 23 ... } sourceSets { main { manifest . srcFile 'AndroidManifest.xml' java . srcDirs = [ 'java' ] resources . srcDirs = [ 'java' ] aidl . srcDirs = [ 'aidl' ] res . srcDirs = [ 'res' ] assets . srcDirs = [ 'assets' ] } } }

You may notice that this has the contents of both previous build.gradle files condensed into one. If we have no intention of supporting multiple modules in the same build project, this is perfectly legal.

The key here, though, is the sourceSets attribute. This maps the source files and directories from their current locations into the Gradle build without requiring us to move them to the locations where Gradle would implicitly search.