Skip to content

Instantly share code, notes, and snippets.

@NickJian
NickJian / gist:389490207a4ba516535629b03dcd7678
Created May 23, 2017 07:20
split apk- build version code setting
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
// Stores the value of ext.abiCodes that is associated with the ABI for this variant.
def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
// Assigns a different version code for each output APK other than the universal APK.
if (baseAbiVersionCode != null) {
output.versionCodeOverride = baseAbiVersionCode * 1000 + variant.versionCode
}
}
@NickJian
NickJian / gist:d7fc35954e75b502df6e2eec05c1ae2f
Created May 23, 2017 07:21
build with property setting
./gradlew -PsplitApks clean assembleRcRelease
splits {
abi {
// Enables building multiple APKs per ABI only when build with property
enable project.hasProperty('splitApks')
reset()
// Resets the list of ABIs that Gradle should create APKs for to none.
// Specifies a list of ABIs that Gradle should create APKs for.
      include "armeabi-v7a", "arm64-v8a", "x86"
// Map for the version code that gives each ABI a value.
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3]
import com.android.build.OutputFile
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
// Stores the value of ext.abiCodes that is associated with the ABI for this variant.
def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
// Assigns a different version code for each output APK other than the universal APK.
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:srcCompat="@drawable/myimage" />
android {
defaultConfig {
...
vectorDrawables.useSupportLibrary = true
}
}
// the textview to show the image
TextView tv1=(TextView)findViewById(R.id.textview);
Typeface typeface=Typeface.createFromAsset(getAssets(),"fonts/iconfont.ttf");
tv1.setTypeface(typeface);
// the unicode you add in tff
// instead of hard code it here, you should put it to your string file or make it to constant, so that it can be managed better.
tv1.setText("\ue600");
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/original_image"
android:fromDegrees="90"
android:pivotX="50%"
android:pivotY="50%"/>
# install android-resource-remover
pip install android-resource-remover
# there's some issue on remover currently, need to move manifest manually
cp ./<pathToManifest>/AndroidManifest.xml AndroidManifest.xml
android-resource-remover --xml <yourLintReport>