Giter Site home page Giter Site logo

dexdiff's Introduction

DexDiff

DexDiff通过反编译新旧dex文件后计算增量dex,并利用旧dex与增量dex生成新dex,可用于实现Android的热修复及增量更新。

原理

  1. 基于dex2jar库反编译新旧dex
  2. 逐个对比新旧dex中的class:
    • class仅存在于旧dex,保存至deleteClasses
    • class仅存在于新dex,保存至replaceClasses
    • class存在于新旧dex,但class数据不一致,保存新dex中的class至replaceClasses
  3. 编译得到的replaceClasses得到replace.dex
  4. 记录deleteClasses中的类签名得到delete.data
  5. 根据replace.dex、delete.data以及旧dex便可以编译得到新dex

Dex2Jar

本项目依赖于dex2jar实现dex文件的编译及反编译,为了实现dexdiff对dex2jar做了如下改动:

  • 修改部分字段为public权限
  • 删除部分字段的final属性
  • 重写部分类的hashCode、equals及toString方法
  • 修改PackedSwitch及SparseSwitch为嵌套类

TODO

目前仅实现了class粒度上的对比,但这套方案完全可以实现method粒度甚至instruction粒度的对比

License

Apache License 2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.