AndResGuard


Source link: https://github.com/shwenzhang/AndResGuard

AndResGuard

Read this in other languages: English, ????.

AndResGuard is a tooling for reducing your apk size, it works like the ProGuard for Java source code, but only aim at the resource files. It changes res/drawable/wechat to r/d/a, and renames the resource file wechat.png to a.png. Finally, it repackages the apk with 7zip, which can reduce the package size obviously.

AndResGuard is fast, and it does NOT need the source codes. Input an Android apk, then we can get a 'ResGuard' apk in a few seconds.

Some uses of AndResGuard are:

  1. Obfuscate android resources. It contains all the resource type(such as drawable?layout?string...). It can prevent your apk from being reversed by Apktool.

  2. Shrinking the apk size. It can reduce the resources.arsc and the package size obviously.

  3. Repackage with 7zip. It supports repackage apk with 7zip, and we can specify the compression method for each file.

AndResGuard is a command-line tool, it supports Windows, Linux and Mac. We suggest you to use 7zip in Linux or Mac platform for a higher compression ratio.

Note: Signature schemeV2 will make 7zip compressing invalid. If you really care about your APK size, please disable v2Signing in your signingConfigs

How to use

With Gradle

This has been released on Bintray

apply plugin: 'AndResGuard'  buildscript {

  repositories {

jcenter()
  
}

  dependencies {

classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.8'
  
}
 
}
  andResGuard {

  // mappingFile = file("./resource_mapping.txt")
  mappingFile = null
  // It will be invalid when you sign apk with schemeV2
  use7zip = true
  useSign = true
  // it will keep the origin path of your resources when it's true
  keepRoot = false

whiteList = [

// your icon

"R.drawable.icon",

// for fabric

"R.string.com.crashlytics.*",

// for google-services

"R.string.google_app_id",

"R.string.gcm_defaultSenderId",

"R.string.default_web_client_id",

"R.string.ga_trackingId",

"R.string.firebase_database_url",

"R.string.google_api_key",

"R.string.google_crash_reporting_api_key"
  ]
  compressFilePattern = [

"*.png",

"*.jpg",

"*.jpeg",

"*.gif",

"resources.arsc"
  ]
  sevenzip {

artifact = 'com.tencent.mm:SevenZip:1.2.8'

//path = "/usr/local/bin/7za"
  
}

/** 
 * Optional: if finalApkBackupPath is null, AndResGuard will overwrite final apk 
 * to the path which assemble[Task] write to 
 **/
  finalApkBackupPath = "${
project.rootDir
}
/final.apk"

/** 
 * Optional: Specifies the name of the message digest algorithm to user when digesting the entries of JAR file 
 * Only works in V1signing, default value is "SHA1" 
 **/
  digestalg = "SHA256" 
}

The whiteList and compressFilePattern support wildcard include ? * +.

? Zero or one character * Zero or more of character + One or more of character 

If you are using Android Studio, you can find the generate task option in andresguard group. Or alternatively, you run ./gradlew resguard[BuildType | Flavor] in your terminal. The format of task name is as same as assemble.

The sevenzip can be set by path or artifact. Mutiple assignments are allowed, but the winner is always path.

The outputted apk will be stored in { App } /build/output/apk/AndResGuard_{ apk_name } /{ apk_name } _signed_7zip_aligned.apk.

You can find more whitsList configs of third-part SDK in white_list.md. Welcome PR your configs which is not included in white_list.md

The whiteList only works on the specsName of resources, it wouldn't keep the path of resource. If you wanna keeping the path, please use mappingFile to implement it.

For example, we wanna keeping the path of icon, we need add below into our mappingFile.

res path mapping:
  res/mipmap-hdpi-v4 -> res/mipmap-hdpi-v4
  res/mipmap-mdpi-v4 -> res/mipmap-mdpi-v4
  res/mipmap-xhdpi-v4 -> res/mipmap-xhdpi-v4
  res/mipmap-xxhdpi-v4 -> res/mipmap-xxhdpi-v4
  res/mipmap-xxxhdpi-v4 -> res/mipmap-xxxhdpi-v4 

Looking for more detail

Known Issue

  1. The first element of list which returned by AssetManager#list(String path) is empty string when you're using the APK which is compressed by 7zip. #162

Thanks

Apktool Connor Tumbleson

v2sig @jonyChina162

Resources

The Android Action Bar Style Generator allows you to easily create a simple, attractive and seamless custom action bar style for your Android application. It will generate all necessary nine patch assets plus associated XML drawables and styles which you can copy straight into your project.

Use it online here: http://jgilfelt.github.com/android-actionbarstylegenerator

An open source project to provide push notification support for Android - a XMPP based notification server and a client tool kit.

android-checkout is a library for Android In-App Billing (v3). The main goal is to reduce work which should be done by developers who want to integrate in-app purchases in their products. The project is inspired by Volley library and is designed to be easy to use, fast and flexible.

Mobile App testing on 300+ real devices!

  • Save in App Development Costs
  • Reduce Risks with Proactive, Agile Testing
  • Speed Up Time to Market
  • Reduce Operational & Unpredictable Costs
  • Improve App Ratings & Brand Reputation

AndroidAsync is a low level network protocol library.

Features:

  • Based on NIO. One thread, driven by callbacks. Highly efficient.
  • All operations return a Future that can be cancelled
  • Socket client + socket server
  • HTTP client + server
  • WebSocket client + server
  • Socket.IO client

This library is an Android networking abstraction library consisting of a combination of Volley, OkHttp, and Jackson, with a little glue to stick it all together. It's a great place to start if you need to execute requests, especially thos which return JSON.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes