Nuwa


Source link: https://github.com/jasonross/Nuwa

Nuwa

Nuwa is a goddess in ancient Chinese mythology best known for repairing the pillar of heaven.

With this Nuwa project?you can also have the repairing power, fix your android applicaiton without have to publish a new APK to the appstore.

Features

  • Support both dalvik and art runtime.
  • Support productFlavor and buildType.
  • Support proguard and multidex.
  • Pure java implementation.

Run the Sample

  1. in master branch, run and install the app.

    it shows?hello world?.

  2. copy sample/build/outputs/nuwa dir to somewhere for later use.

    for example: /Users/jason/Documents/nuwa

  3. change to bugfix branch, run the following command in terminal to generate patch.jar.

    ./gradlew clean nuwaQihooDebugPatch -P NuwaDir=/Users/jason/Documents/nuwa

    java verison must be same using android studio and terminal

  4. run following command to push patch.jar to sdcard.

    adb push sample/build/outputs/nuwa/qihoo/debug/patch.jar /sdcard/

  5. restart your application (kill the process).

    it shows?patch success?.

Integration

Get Gradle Plugin

  1. add following to the build.gradle of your root project.

classpath 'cn.jiajixin.nuwa:gradle:1.2.2'

build.gradle maybe look like this:  ``` buildscript {

  repositories {

jcenter()
  
}

  dependencies {

classpath 'com.android.tools.build:gradle:1.2.3'

classpath 'cn.jiajixin.nuwa:gradle:1.2.2'
  
}
 
}
 ``` 
  1. add following to your build.gradle:

    apply plugin: "cn.jiajixin.nuwa"

Get Nuwa SDK

  • gradle dependency:

     dependencies {
    
    compile 'cn.jiajixin.nuwa:nuwa:1.0.0'  
    }
     

Use Nuwa SDK

  1. add following to your application class:

    @Override protected void attachBaseContext(Context base) {
    
      super.attachBaseContext(base);
    
      Nuwa.init(this);
     
    }
     
  2. load the patch file according to your needs:

    Nuwa.loadPatch(this,patchFile) 

    I plan to provide the management of patch file later.

ProGuard

  • add follwing to you proguardFile if you are using proguard:

    -keep class cn.jiajixin.nuwa.** { *; }

Nuwa DSL

  1. You can add nuwa extension to your build.gradle. Generally, you don't need this.

    nuwa{
      
    }
     
  2. Nuwa extension support following DSL object.

    • includePackage:HashSet<String>

      The internal name of a class is its fully qualified name, where '.' are replaced by '/'. For example:

      cn/jiajixin/nuwasample/MainActivity.class

      Using includePackage?you can only fix those classes whose internal name starts with includePackage.For example:

    includePackage = ['cn/jiajixin/nuwasample']

     Default, Nuwa can fix classes which not from the android support library. 
    • excludeClass:HashSet<String>

      All Application subclasses should not be injected by Nuwa.

      Default, Nuwa will automatically exclude the application declared in your manifest file. You need to exclude others using excludeClass

      Using excludeClass, you can not fix those classes whose internal name ends with excludeClass.For example:

      excludeClass = ['BaseApplication.class']

    • debugOn:boolean

      whether use Nuwa in debug mode, default to true.

Generate Patch

For how to generate patch file, please reference the first three steps of Run the Sample.

There are two types of gradle task to generate patch file?

  • nuwaPatches

    this task will generate multi patch.jar for all variant.

  • nuwa${ variant.name.capitalize() } Patch

    this task will generate one patch.jar for specific variant.

How it Works

Inspired by QZone hotfix solution from this article.

Nuwa Gradle

  • inject into all classes one java bytecode referring the Hack.class from a different dex, which can avoid CLASS_ISPREVERIFIED error when replacing class.
  • generate patch.jar according to mapping.txt and classes hash of last published APK.

Nuwa

  • inject the Hack.class.
  • inject the patch.jar into head of BaseDexClassLoader's pathList.

Later Plan

  • provide patch file management
  • improve security of Nuwa

License

The MIT License (MIT)

Copyright (c) 2015, jiajixin.cn

Resources

Another sliding menu base on DrawerLayout.

AutoTypeTextView is simple library which add encryption, decryption and texting animations.

Android library allowing to preserve instance of any object across orientation changes.

Android Library for auto-formatting money on EditText.

Restito is a tool which is inspired by mockito and functionally is diametrically opposite to the Rest Assured.

Restito provides a DSL to:

  • Mimic rest server behavior
  • Record HTTP calls to the server
  • Perform verification against happened calls

Testing and validation of REST services in Java is harder than in dynamic languages such as Ruby and Groovy. REST Assured brings the simplicity of using these languages into the Java domain.

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