Created
July 27, 2018 22:13
-
-
Save tmtrademarked/49de4066f357636c858e7bccc2f1a139 to your computer and use it in GitHub Desktop.
Manual Crashlytics Proguard uploader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Temporary work-around script for uploading a proguard file. Based on a version | |
# found here: https://gist.github.com/jakeouellette/608d934efaaf50b3cb15886e66009664 | |
# | |
# NOTE - this file assumes you've already run the build, and that you are using | |
# Crashlytics via the Firebase plugin and Google Play Services. Your mileage may | |
# vary based on your needs. | |
# Copyright 2017 Google Inc. | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
file=io-fabric-tools-gradle.jar # Define the plugin name so that we can download & execute it | |
get_fabric_tool () { | |
path=https://maven.fabric.io/public/io/fabric/tools/gradle | |
version=$(curl -Ls $path/maven-metadata.xml | grep release | sed "s/.*<release>\([^<]*\)<\/release>.*/\1/") | |
echo $version | |
if [ -f $file ]; then | |
# Use a cached tool if it exists. | |
echo using cached fabric tool, "$file" | |
else | |
jar=gradle-"$version".jar | |
echo downloading latest fabric tool, "$path/$version/$jar" | |
wget -q -N "$path/$version/$jar" # You can use curl -O "$path/$version/$jar" instead if you don't have wget. | |
mv gradle-"$version".jar "$file" # Rename so it has a predictable name | |
fi | |
} | |
run_task () { | |
args="$1-projectPath $project_path \n" | |
args="$args-androidManifest $manifest_path \n" | |
args="$args-androidBaseManifest $base_manifest_path \n" | |
args="$args-androidRes $res_path \n" | |
args="$args-androidAssets $assets_path \n" | |
args="$args-googleServicesResDir $google_path \n" | |
args="$args-buildId $build_id \n" | |
args="$args-targetResValueDir $target_res_values_dir \n" | |
args="$args-version 0.0 \n" | |
args="$args-tool shell \n" | |
if [ ! "$properties" = '' ] ; then | |
args="$args-properties $properties \n" | |
fi | |
run_tool "$args" | |
} | |
run_tool () { | |
echo "$@" | |
echo "$@" | tr -d "\n" | xargs java -cp $file com.crashlytics.tools.android.DeveloperTools gradleMain | |
} | |
generate_resources () { | |
args="-buildEvent \n" | |
args="$args-injectableManifest \n" | |
target_res_file="$target_res_values_dir"/values/com_crashlytics_export_strings.xml | |
if [ "$preserve_build_id" = true ] && [ -f "$target_res_file" ] ; then | |
args="$args-preserveBuildId" | |
fi | |
run_task "-generateResourceFile \n$args" | |
} | |
store_deobs () { | |
args="-obfuscator proguard \n" | |
args="$args-obVer 0.0 \n" | |
args="$args-obfuscating \n" | |
run_task "-storeDeobs $mapping_file \n$args" | |
} | |
upload_deobs () { | |
run_task "-uploadDeobs -requireUploadSuccess \n" | |
} | |
pre_build () { | |
generate_resources | |
store_deobs | |
} | |
post_build () { | |
upload_deobs | |
} | |
find_build_id () { | |
echo `cat $project_path/build/generated/fabric/res/$flavor/values/com_crashlytics_build_id.xml | grep build_id | sed -n 's:.*<string.*>\(.*\)</string>.*:\1:p'` | |
} | |
# Adjust these as necessary for your app. | |
project_path=mobile | |
flavor=release | |
# These are all derived from the default Android outputs. You probably don't need to change these. | |
preserve_build_id=false | |
mapping_file=$project_path/build/outputs/mapping/$flavor/mapping.txt | |
manifest_path=$project_path/build/intermediates/merged_manifests/$flavor/processReleaseManifest/merged/AndroidManifest.xml | |
base_manifest_path=$project_path/src/main/AndroidManifest.xml | |
res_path=$project_path/src/main/res | |
assets_path=$project_path/build/intermediates/merged_assets/$flavor/mergeReleaseAssets/out | |
target_res_values_dir=$project_path/build/generated/fabric/res/$flavor | |
google_path=$project_path/build/generated/res/google-services/$flavor | |
properties='' | |
build_id=$(find_build_id) | |
echo "Uploading mapping for build ${build_id}" | |
get_fabric_tool | |
pre_build | |
post_build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment