Files
MapLibreParticleLab/android/MapboxGLAndroidSDKTestApp/build.gradle
Stephen Niedzielski 9747caa435 Fix Android ProGuard View rules & release signing
- Enable ProGuard for the test app so the most common use case may be tested.
- Update ProGuard to keep all Mapbox views and their methods.
  Previously, ProGuard was stripping numerous class methods including
  UserLocationView.g/setAccuracy(). These particular methods are
  accessed via reflection. On newer APIs, this manifests only in Logcat
  and loss of functionality:

   PropertyValuesHolder  W  Method setAccuracy() with type float not found on target class class com.mapbox.mapboxsdk.views.UserLocationView
                         W  Method getAccuracy() with type null not found on target class class com.mapbox.mapboxsdk.views.UserLocationView

  On Android 4.03 and 4.04 (API 15), this causes an NPE:

    java.lang.NullPointerException
      at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:513)
      at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:385)
      at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:537)
      at android.animation.ValueAnimator.start(ValueAnimator.java:927)
      at android.animation.ValueAnimator.start(ValueAnimator.java:950)
      at android.animation.ObjectAnimator.start(ObjectAnimator.java:363)
      at com.mapbox.mapboxsdk.views.UserLocationView.setLocation(UserLocationView.java:401)
      at com.mapbox.mapboxsdk.views.UserLocationView.toggleGps(UserLocationView.java:300)
      at com.mapbox.mapboxsdk.views.UserLocationView.setEnabled(UserLocationView.java:230)
      at com.mapbox.mapboxsdk.views.MapView.setMyLocationEnabled(MapView.java:3122)
      ...

  Also add Support libraries rules to the test. Further amendments may
  be made by examining usage.txt[0,1].

[0] http://developer.android.com/tools/help/proguard.html#enabling
[1] http://proguard.sourceforge.net/manual/usage.html#shrinkingoptions
2015-12-10 20:47:11 -08:00

114 lines
3.4 KiB
Groovy

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'android-sdk-manager'
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"
defaultConfig {
applicationId "com.mapbox.mapboxgl.testapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 6
versionName "2.2.0"
// Specify AndroidJUnitRunner as the default test instrumentation runner
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
}
lintOptions {
checkAllWarnings true
warningsAsErrors true
disable 'IconDensities'
disable 'InvalidPackage'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile(project(':MapboxGLAndroidSDK')) {
transitive = true
}
compile 'com.android.support:support-annotations:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
// Testing dependencies
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.android.support:support-annotations:23.1.0'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
}
checkstyle {
configFile project.file('../checks.xml')
showViolations true
}
android.applicationVariants.all { variant ->
def name = variant.buildType.name
def checkstyle = project.tasks.create "checkstyle${name.capitalize()}", Checkstyle
checkstyle.dependsOn variant.javaCompile
checkstyle.source variant.javaCompile.source
checkstyle.classpath = project.fileTree(variant.javaCompile.destinationDir)
checkstyle.exclude('**/BuildConfig.java')
checkstyle.exclude('**/R.java')
project.tasks.getByName("check").dependsOn checkstyle
}