Code Monkey home page Code Monkey logo

hot_fix's Introduction

hot_fix

!! 测试

在Android中,由于flutter使用了FlutterInjector,我们可以自定义加载方式, 使用最简单粗暴的方法:全量更新,插入classes.dex,更换libapp.so.

描述

url:baseUrl/versionName/versionNumber/abi/appName
比如:http://192.168.1.127:8080/1.0.0/1/arm64-v8a/libapp.so

baseUrl下,文件结构:

│  majorversion.json
│  
└─1.1.0
    │  minversion.json
    │  
    └─0
        │  classes.dex
        │  classes.dex.sha256
        │  
        ├─arm64-v8a
        │      libapp.so
        │      libapp.so.sha256
        │      
        ├─armeabi-v7a
        │      libapp.so
        │      libapp.so.sha256
        │      
        └─x86_64
                libapp.so
                libapp.so.sha256

versionNameversionNumberpubspec.yaml中的version信息,
如:version: 1.0.0+1 versionName = 1.0.0, versionNumber = 1
majorversion.jsonminversion.json格式一样,

{"versionName":"1.1.0","versionNumber":"1"}

majorversion.json的信息应该是最新版本的信息,更新classes.dexlibapp.sominversion.json在versionName下,指定当前版本下最新versionNumber版本,只会更新libapp.so

java

继承HotFixApplicationHotFixActivity:

class MyApplication extends HotFixApplication {}
class MyActivity extends HotFixActivity {}

libs为每一个abi创建一个文件:libapp_stamp_$abi.so

修改flutter_tools收集所需文件

可以为flutter插入示例补丁:patch/flutter_2.6.0.path 直接生成除了majorversion.json所有文件,生成文件在build/deferred_libs下, 在 flutter 根目录下:

git apply path/to/futter_2.6.0.patch

如果无法应用补丁,也可以手动修改flutter_tools
记得要删除cache/flutter_tools.snapshot,会自动重新构建更改的版本

在项目中使用:

...
import 'package:hot_fix/hot_fix.dart';
...
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  if (defaultTargetPlatform == TargetPlatform.android) {
    final hot = DeferredMain(
        versionName: versionName,
        versionNumber: versionNumber,
        baseUrl: 'http://192.168.1.127:8080/shudu/');
    await hot.initState();
  }
  runApp(...);
}

hot_fix's People

Contributors

sersr avatar

Watchers

 avatar

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.