Skip to content

Instantly share code, notes, and snippets.

@skyisle
Last active August 29, 2015 14:19
Show Gist options
  • Save skyisle/d10116f4112c6c1dd6ae to your computer and use it in GitHub Desktop.
Save skyisle/d10116f4112c6c1dd6ae to your computer and use it in GitHub Desktop.
Install android support library snapshot to local repository
#!/bin/bash
# Fix the CircleCI path
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH"
DEPS="$ANDROID_HOME/installed-support-furture"
if [ ! -e $DEPS ]; then
echo y | android update sdk -u -a -t android-4 &&
echo y | android update sdk -u -a -t android-5 &&
echo y | android update sdk -u -a -t android-7 &&
echo y | android update sdk -u -a -t android-8 &&
echo y | android update sdk -u -a -t android-9 &&
echo y | android update sdk -u -a -t android-11 &&
echo y | android update sdk -u -a -t android-12 &&
echo y | android update sdk -u -a -t android-13 &&
echo y | android update sdk -u -a -t android-14 &&
echo y | android update sdk -u -a -t android-15 &&
echo y | android update sdk -u -a -t android-16 &&
echo y | android update sdk -u -a -t android-17 &&
echo y | android update sdk -u -a -t android-18 &&
echo y | android update sdk -u -a -t android-19 &&
echo y | android update sdk -u -a -t android-21 &&
echo y | android update sdk -u -a -t android-22 &&
echo y | android update sdk -u -a -t build-tools-19.0.3 &&
echo y | android update sdk -u -a -t build-tools-19.0.1 &&
export ANDROID_SUPPORT_M2REPO="$ANDROID_HOME/extras/android/m2repository" &&
export PLATFORMS_DIR="$ANDROID_HOME/platforms/" &&
rm -rf support-lib &&
git clone https://android.googlesource.com/platform/frameworks/support support-lib &&
cd support-lib &&
rm -rf local.properties &&
sed -i.bak "s/distributionUrl=..\/..\/..\/..\/tools\/external\/gradle\/gradle-1.11-bin.zip/distributionUrl=https\\\:\/\/services.gradle.org\/distributions\/gradle-1.11-bin.zip/g" gradle/wrapper/gradle-wrapper.properties &&
sed -i.bak "s/ext.supportVersion = '21.0.3'/ext.supportVersion = '22.0.1-SNAPSHOT'/g" build.gradle &&
sed -i.bak "s/maven { url '..\/..\/prebuilts\/gradle-plugin' }/jcenter()/g" build.gradle &&
sed -i.bak "s/createSourceProp.dependsOn unzipRepo/\/\/createSourceProp.dependsOn unzipRepo/g" build.gradle &&
sed -i.bak "s/buildDir = file('..\/..\/out\/host\/gradle\/frameworks\/support\/build')/buildDir = file('build')/g" build.gradle &&
sed -i.bak "s/project.ext.distDir = file('..\/..\/out\/dist')/project.ext.distDir = file(System.env.ANDROID_SUPPORT_M2REPO)/g" build.gradle &&
sed -i.bak "s/ext.supportRepoOut = new File(buildDir, 'support_repo')/ext.supportRepoOut = new File\(project.ext.distDir, ''\)/g" build.gradle &&
sed -i.bak "s/files(\"\$rootDir\/..\/..\/prebuilts\/sdk\/\$apiLevel\/android.jar\")/files(System.env.PLATFORMS_DIR + \"\/android-\$apiLevel\/android.jar\")/g" build.gradle &&
sed -i.bak "s/'current', api21SS/'22', api21SS/g" v4/build.gradle &&
find . -name "*.gradle" -print | xargs sed -i.bak "s/compileSdkVersion 'current'/compileSdkVersion 22/g" &&
find . -name "*.gradle" -print | xargs sed -i.bak "s/android.plugin.sdkDirectory/android.sdkDirectory/g" &&
find . -name "*.gradle" -print | xargs sed -i.bak "s/getAndroidPrebuilt('current')/getAndroidPrebuilt('22')/g" &&
mkdir -p build/support_repo &&
./gradlew release &&
touch $DEPS
fi
@skyisle
Copy link
Author

skyisle commented Apr 20, 2015

and add dependencies to your build.gradle

dependencies {
  compile "com.android.support:support-v4:22.0.1-SNAPSHOT"
  compile "com.android.support:design:22.0.1-SNAPSHOT"
  compile "com.android.support:appcompat-v7:22.0.1-SNAPSHOT"
  compile "com.android.support:recyclerview-v7:22.0.1-SNAPSHOT"
  compile "com.android.support:cardview-v7:22.0.1-SNAPSHOT"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment