apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "20.0.0" lintOptions { // This is important as it will run lint but not abort on error // Lint has some overly obnoxious "errors" that should really be warnings abortOnError false } defaultConfig { applicationId "org.dolphinemu.dolphinemu" minSdkVersion 18 targetSdkVersion 21 versionCode 13 versionName "0.13" } signingConfigs { release { if (project.hasProperty('keystore')) { storeFile file(project.property('keystore')) storePassword project.property('storepass') keyAlias project.property('keyalias') keyPassword project.property('keypass') } } } // Define build types, which are orthogonal to product flavors. buildTypes { // Signed by release key, allowing for upload to Play Store. release { signingConfig signingConfigs.release } // Signed by debug key disallowing distribution on Play Store. // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build. debug { applicationIdSuffix ".debug" versionNameSuffix '-debug' jniDebuggable true tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn(compileNative) } } } // Define product flavors, which can be split into categories. Common examples // of product flavors are paid vs. free, ARM vs. x86, etc. productFlavors { arm { // This flavor is mutually exclusive against any flavor in the same dimension. flavorDimension "abi" // When building this flavor, only include native libs from the specified folder. ndk { abiFilter "armeabi-v7a" } } arm_64 { flavorDimension "abi" ndk { abiFilter "arm64-v8a" } } // TODO Uncomment this when we successfully build for x86_64. /*x86_64 { flavorDimension "abi" ndk { abiFilter "x86_64" } }*/ } } dependencies { compile 'com.android.support:support-v4:22.1.1' compile 'com.android.support:support-v13:22.0.0' compile 'com.android.support:cardview-v7:21.0.3' compile 'com.android.support:recyclerview-v7:21.0.3' // For showing the banner as a circle a-la Material Design Guidelines compile 'de.hdodenhof:circleimageview:1.2.2' // For loading huge screenshots from the disk. compile 'com.squareup.picasso:picasso:2.5.2' } task setupCMake(type: Exec) { // Check if a build properties file exists. def propsFile = rootProject.file("build.properties") // If it does, call CMake. if (propsFile.canRead()) { // Read the properties file's contents. def buildProperties = new Properties() buildProperties.load(new FileInputStream(propsFile)) mkdir('build/' + buildProperties.abi) workingDir 'build/' + buildProperties.abi executable 'cmake' args "-DANDROID=true", "-DANDROID_NATIVE_API_LEVEL=android-18", "-DCMAKE_TOOLCHAIN_FILE=../../../android.toolchain.cmake", "../../../../..", "-DGIT_EXECUTABLE=" + getGitPath(), "-DANDROID_NDK=" + getNdkPath(), "-DANDROID_TOOLCHAIN_NAME=" + buildProperties.toolchain, "-DANDROID_ABI=" + buildProperties.abi } else { executable 'echo' args 'No build.properties found; skipping CMake.' } } task compileNative(type: Exec, dependsOn: 'setupCMake') { // Check if a build properties file exists. def propsFile = rootProject.file("build.properties") // If it does, call make. if (propsFile.canRead()) { // Read the properties file's contents. def buildProperties = new Properties() buildProperties.load(new FileInputStream(propsFile)) workingDir 'build/' + buildProperties.abi executable 'make' args buildProperties.makeArgs } else { executable 'echo' args 'No build.properties found; skipping native build.' } } String getGitPath() { try { def stdout = new ByteArrayOutputStream() exec { commandLine 'which', 'git' standardOutput = stdout } def gitPath = stdout.toString().trim() project.logger.quiet("Gradle: Found git executuable:" + gitPath) return gitPath } catch (ignored) { // Shouldn't happen. How did the user get this file without git? project.logger.error("Gradle error: Couldn't find git executable.") return null; } } String getNdkPath() { try { def stdout = new ByteArrayOutputStream() exec { // ndk-build.cmd is a file unique to the root directory of android-ndk-r10d. commandLine 'locate', 'ndk-build.cmd' standardOutput = stdout } def ndkCmdPath = stdout.toString() def ndkPath = ndkCmdPath.substring(0, ndkCmdPath.lastIndexOf('/')) project.logger.quiet("Gradle: Found Android NDK:" + ndkPath) return ndkPath } catch (ignored) { project.logger.error("Gradle error: Couldn't find NDK.") return null; } }