Skip to content

Commit

Permalink
Upgrade example build (dropbox#339)
Browse files Browse the repository at this point in the history
* example: Guard against ndkDir being null at configuration time

This is a follow-up to PR dropbox#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
  • Loading branch information
sschuberth authored and KhalilBellakrid committed Mar 8, 2018
1 parent 6e9464d commit 93cd135
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
29 changes: 16 additions & 13 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "26.0.0"

defaultConfig {
applicationId "com.dropbox.textsort"
Expand All @@ -27,33 +26,37 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.findbugs:jsr305:3.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.code.findbugs:jsr305:3.0.0'
}

task ndkBuild(type: Exec) {
File ndkDir = project.android.ndkDirectory
def ndkBuildExecutable = new File(ndkDir, 'ndk-build')
def ndkDir = project.android.ndkDirectory
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 {
if (ndkDir == null) {
if (!ndkDir) {
def gradle_project_root = project.rootProject.rootDir
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}.")
}

if (!ndkBuildExecutable.exists()) {
if (!ndkBuildExecutable.file) {
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) {
compileTask -> compileTask.dependsOn ndkBuild
}

3 changes: 2 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

buildscript {
repositories {
google()
jcenter()
}
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
// in the individual module build.gradle files
Expand Down
Binary file modified example/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
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

0 comments on commit 93cd135

Please sign in to comment.