diff options
-rw-r--r-- | android/MapboxGLAndroidSDKTestApp/build.gradle | 19 | ||||
-rw-r--r-- | docs/DEVELOP_ANDROID_LINUX.md | 2 | ||||
-rw-r--r-- | docs/DEVELOP_ANDROID_OSX.md | 2 |
3 files changed, 21 insertions, 2 deletions
diff --git a/android/MapboxGLAndroidSDKTestApp/build.gradle b/android/MapboxGLAndroidSDKTestApp/build.gradle index 7283d2d067..bdb4837211 100644 --- a/android/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/MapboxGLAndroidSDKTestApp/build.gradle @@ -15,6 +15,25 @@ apply plugin: 'com.android.application' apply plugin: 'io.fabric' apply plugin: 'checkstyle' +task accessToken { + def tokenFile = new File("MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml") + if (!tokenFile.exists()) { + String tokenFileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + " <string name=\"access_token\">" + "$System.env.MAPBOX_ACCESS_TOKEN" + "</string>\n" + + "</resources>" + + if (tokenFileContents == null) { + throw new InvalidUserDataException("You must set the MAPBOX_ACCESS_TOKEN environment variable.") + } + tokenFile.write(tokenFileContents) + } +} + +gradle.projectsEvaluated { + preBuild.dependsOn('accessToken') +} + android { compileSdkVersion 23 buildToolsVersion "23.0.2" diff --git a/docs/DEVELOP_ANDROID_LINUX.md b/docs/DEVELOP_ANDROID_LINUX.md index 31e7f193e9..7a918299d6 100644 --- a/docs/DEVELOP_ANDROID_LINUX.md +++ b/docs/DEVELOP_ANDROID_LINUX.md @@ -21,7 +21,7 @@ In the Android SDK Manager also select and install "Android Support Repository" _The demo applications use Mapbox vector tiles, which require a Mapbox account and API access token. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/account/apps/)._ -gradle will take the value of the `MAPBOX_ACCESS_TOKEN` environ variable and save it to `android/java/MapboxGLAndroidSDK/src/main/res/raw/token.txt` where the app will read it from. +gradle will take the value of the `MAPBOX_ACCESS_TOKEN` environ variable and save it to `"MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml` where the app will read it from. ## Building diff --git a/docs/DEVELOP_ANDROID_OSX.md b/docs/DEVELOP_ANDROID_OSX.md index 2bc8853686..c98c1e6553 100644 --- a/docs/DEVELOP_ANDROID_OSX.md +++ b/docs/DEVELOP_ANDROID_OSX.md @@ -19,7 +19,7 @@ By default, the Android SDK will be installed to `/Users/<user>/Library/Android/ _The test application (used for development purposes) uses Mapbox vector tiles, which require a Mapbox account and API access token. Obtain a free access token on the [Mapbox account page](https://www.mapbox.com/account/apps/)._ -gradle will take the value of the `MAPBOX_ACCESS_TOKEN` environ variable and save it to `android/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt` where the app will read it from. +gradle will take the value of the `MAPBOX_ACCESS_TOKEN` environ variable and save it to `MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml` where the app will read it from. ## Developing In Android Studio |