Commit 565425de authored by Sebastian Schuberth's avatar Sebastian Schuberth Committed by Xianwen Chen

Upgrade example build (#339)

* example: Guard against ndkDir being null at configuration time

This is a follow-up to PR #329.

* example: Upgrade to Android Gradle plugin 3.0.1

Each version of the Android Gradle Plugin now has a default version of the
build tools. The "compile" configuration was renamed to "implementation".

* example: Upgrade to Gradle 4.4.1
parent 86ba6b5d
...@@ -2,7 +2,6 @@ apply plugin: 'com.android.application' ...@@ -2,7 +2,6 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion "26.0.0"
defaultConfig { defaultConfig {
applicationId "com.dropbox.textsort" applicationId "com.dropbox.textsort"
...@@ -27,33 +26,37 @@ android { ...@@ -27,33 +26,37 @@ android {
} }
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.findbugs:jsr305:3.0.0' implementation 'com.google.code.findbugs:jsr305:3.0.0'
} }
task ndkBuild(type: Exec) { task ndkBuild(type: Exec) {
File ndkDir = project.android.ndkDirectory def ndkDir = project.android.ndkDirectory
def ndkBuildExecutable = new File(ndkDir, 'ndk-build') def ndkBuildExecutable
if (ndkDir) {
ndkBuildExecutable = new File(ndkDir, 'ndk-build')
def MainDirectory = System.getProperty("user.dir") + '/app/'
environment("NDK_PROJECT_PATH", MainDirectory)
environment("GYP_CONFIGURATION", "Release")
commandLine ndkBuildExecutable
}
doFirst { doFirst {
if (ndkDir == null) { if (!ndkDir) {
def gradle_project_root = project.rootProject.rootDir def gradle_project_root = project.rootProject.rootDir
throw new GradleException("NDK is not configured. Make sure there is a local.properties " + throw new GradleException("NDK is not configured. Make sure there is a local.properties " +
"file with an ndk.dir entry in the directory ${gradle_project_root}.") "file with an ndk.dir entry in the directory ${gradle_project_root}.")
} }
if (!ndkBuildExecutable.exists()) { if (!ndkBuildExecutable.file) {
throw new GradleException("Could not find ndk-build. The configured NDK directory ${ndkDir} may not be correct.") throw new GradleException("Could not find ndk-build. The configured NDK directory ${ndkDir} may not be correct.")
} }
} }
String MainDirectory = System.getProperty("user.dir") + '/app/'
environment("NDK_PROJECT_PATH", MainDirectory)
environment("GYP_CONFIGURATION", "Release")
commandLine ndkBuildExecutable
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild compileTask -> compileTask.dependsOn ndkBuild
} }
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
buildscript { buildscript {
repositories { repositories {
google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
......
...@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME ...@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment