Convert Figma logo to code with AI

dodola logoRocooFix

another hotfix framework

1,571
292
1,571
50

Top Related Projects

43,026

A type-safe HTTP client for Android and the JVM

17,430

A fast dependency injector for Android and Java.

Bind Android views and callbacks to fields and methods.

47,869

RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

50,119

Google core libraries for Java

Quick Overview

RocooFix is a runtime hot-fix solution for Android applications, allowing developers to quickly patch and update their apps without the need for a full app update. It provides a simple and efficient way to fix bugs or introduce new features without going through the app store review process.

Pros

  • Runtime Patching: RocooFix enables developers to apply hot-fixes to their apps without requiring users to update the app.
  • Reduced Downtime: With RocooFix, developers can quickly address issues and push updates to users, minimizing app downtime and improving user experience.
  • Streamlined Deployment: The solution simplifies the deployment process, allowing developers to focus on delivering new features and bug fixes.
  • Compatibility: RocooFix is compatible with a wide range of Android versions, making it a versatile solution for diverse user bases.

Cons

  • Potential Security Risks: Runtime patching can introduce security vulnerabilities if not implemented properly, as it allows for dynamic code execution.
  • Complexity: Integrating RocooFix into an existing project may require additional setup and configuration, which can add complexity to the development process.
  • Dependency on External Service: RocooFix relies on an external service (Rocoo) to manage and distribute the hot-fixes, which introduces a potential single point of failure.
  • Limited Visibility: Developers may have limited visibility into the deployment and usage of hot-fixes, making it challenging to monitor and troubleshoot issues.

Code Examples

// Initializing RocooFix
RocooFix.init(this, "YOUR_APP_ID");

This code initializes the RocooFix library, setting the application ID for the current app.

// Applying a hot-fix
RocooFix.getInstance().applyPatch("path/to/patch.jar");

This code applies a hot-fix by loading a patch file located at the specified path.

// Checking the hot-fix status
boolean isPatched = RocooFix.getInstance().isPatchApplied();

This code checks whether a hot-fix has been successfully applied to the app.

// Clearing the hot-fix
RocooFix.getInstance().clearPatch();

This code removes the applied hot-fix, reverting the app to its original state.

Getting Started

To get started with RocooFix, follow these steps:

  1. Add the RocooFix dependency to your project's build.gradle file:
dependencies {
    implementation 'com.dodola:rocoofix:1.0.6'
}
  1. Initialize RocooFix in your application's onCreate() method:
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        RocooFix.init(this, "YOUR_APP_ID");
    }
}
  1. Create a hot-fix patch and upload it to the Rocoo service. You can use the provided RocooFix.applyPatch() method to apply the hot-fix in your app.

  2. Monitor the hot-fix status using the RocooFix.isPatchApplied() method, and handle any issues or rollbacks as needed.

For more detailed instructions and advanced usage, please refer to the RocooFix GitHub repository.

Competitor Comparisons

43,026

A type-safe HTTP client for Android and the JVM

Pros of Retrofit

  • Widely adopted and well-documented library for making HTTP requests in Android applications.
  • Provides a clean and intuitive API for defining and executing API calls.
  • Supports a variety of response types, including JSON, XML, and custom data formats.

Cons of Retrofit

  • Requires more boilerplate code to set up and configure compared to RocooFix.
  • May have a steeper learning curve for developers new to the library.

Code Comparison

Retrofit:

public interface GitHubService {
    @GET("users/{user}/repos")
    Call<List<Repo>> listRepos(@Path("user") String user);
}

RocooFix:

public class FixedMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        // Implement custom logic to fix method invocation
        return proxy.invokeSuper(obj, args);
    }
}
17,430

A fast dependency injector for Android and Java.

Pros of Dagger

  • Dagger is a well-established and widely-used dependency injection framework, with a large and active community.
  • Dagger provides a robust and flexible dependency management system, making it easier to manage complex application architectures.
  • Dagger is highly performant, with a focus on compile-time code generation for efficient runtime performance.

Cons of Dagger

  • Dagger has a steeper learning curve compared to RocooFix, especially for developers new to dependency injection.
  • Dagger's code generation can make it more difficult to debug and understand the underlying implementation.
  • Dagger may be overkill for smaller projects or simple dependency management needs.

Code Comparison

Dagger:

@Module
public class AppModule {
    @Provides
    @Singleton
    public SharedPreferences provideSharedPreferences(Application application) {
        return application.getSharedPreferences("app_prefs", Context.MODE_PRIVATE);
    }
}

RocooFix:

public class RocooFixManager {
    public static void init(Application application) {
        RocooFix.init(application);
    }

    public static void register(Class<?> clazz) {
        RocooFix.register(clazz);
    }
}

Bind Android views and callbacks to fields and methods.

Pros of Butterknife

  • Simplicity: Butterknife provides a straightforward and easy-to-use API for binding views and click listeners, reducing boilerplate code.
  • Performance: Butterknife's annotation-based approach is more efficient than manual view lookups, as it generates optimized code at compile-time.
  • Testability: Butterknife's separation of concerns makes it easier to write unit tests for your Android components.

Cons of Butterknife

  • Dependency on Annotation Processing: Butterknife relies on annotation processing, which can increase build times and complexity.
  • Limited Functionality: Butterknife is primarily focused on view binding and click listeners, and may not provide the same level of flexibility as other view binding solutions.

Code Comparison

Butterknife:

class ExampleActivity extends Activity {
  @BindView(R.id.title) TextView title;
  @BindView(R.id.subtitle) TextView subtitle;

  @OnClick(R.id.button) void onButtonClicked() {
    // TODO: handle click
  }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_example);
    ButterKnife.bind(this);
  }
}

RocooFix:

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView textView = (TextView) findViewById(R.id.textView);
        textView.setText("Hello World!");
    }
}
47,869

RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

Pros of RxJava

  • Provides a powerful and flexible reactive programming model for Java and Android development.
  • Offers a wide range of operators and utilities for working with asynchronous data streams.
  • Has a large and active community with extensive documentation and resources.

Cons of RxJava

  • Steep learning curve, especially for developers new to reactive programming.
  • Can lead to complex and difficult-to-debug code if not used judiciously.
  • Overhead and performance considerations, especially for simple use cases.

Code Comparison

RxJava:

Observable.just("Hello", "World")
    .map(String::toUpperCase)
    .subscribe(System.out::println);

RocooFix:

public class FixedClass {
    public void doSomething() {
        System.out.println("RocooFix is working!");
    }
}
50,119

Google core libraries for Java

Pros of Guava

  • Guava is a well-established and widely-used library, with a large community and extensive documentation.
  • Guava provides a wide range of utility classes and methods, covering a variety of common programming tasks.
  • Guava is actively maintained and regularly updated, ensuring compatibility with the latest Java versions.

Cons of Guava

  • Guava can be a large and complex library, which may be overkill for smaller projects.
  • The learning curve for Guava can be steep, as it introduces its own conventions and patterns.

Code Comparison

Guava:

Optional<Integer> value = Optional.of(42);
if (value.isPresent()) {
    int x = value.get();
    // do something with x
}

RocooFix:

int value = 42;
if (value != 0) {
    // do something with value
}

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

RocooFix

Another hotfix framework

update

新写了一个框架原理与美团robust框架类似,具体看这里:AnoleFix

之前的HotFix项目太过简单,也有很多同学用Nuwa遇到很多问题,作者也不再修复,所以重新构建了一套工具。

遇到问题的同学可以看一下这里

https://github.com/shoyu666/derocoodemo

Bugfix

  1. 2016-06-26
    • 增加了 Android N (API 24)的支持
    • 增加了关联引用的补丁制作模块,解决 ART NativeCode address 位置错误引起的崩溃问题,但是会造成包大小的增加,后期会支持微信提出的 Dexdiff 技术

Features

  • 支持两种模式:
    1. 静态修复某种情况下需要重启应用。
    2. 动态修复,无需重启应用即可生效。
    3. 新增so修复,beta中
  • 支持DalvikVM和ART VM
  • 制作补丁更加方便
  • 支持com.android.tools.build:gradle:1.3.0->com.android.tools.build:gradle:2.1.2 (解决了Nuwa 这个issue)
  • 支持混淆和Mulitdex
  • 无需关注hash.txt和mapping.txt文件的生成和保存

TODO

  • 补充单测
  • 兼容性测试
  • 目录规则调整
  • 对Win系统的支持

Use

public class RocooApplication extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        //初始化
        RocooFix.init(this);
    }
}


//方案1:静态启用,一般在Application里加载补丁
/**
  * 从Assets里取出补丁,一般用于测试
  *
  * @param context
  * @param assetName
  */
RocooFix.initPathFromAssets(Context context, String assetName);
 /**
   * 从指定目录加载补丁
   * @param context
   * @param dexPath
   */
RocooFix.applyPatch(Context context, String dexPath);


//方案2:动态打补丁,立即生效,有性能问题,适用于补丁方法数较少的情况,建议在ART虚拟机里启用该模式
/**
 * 从Asset里加载补丁,一般用于本地测试
 * @param context
 * @param assetName
 */
RocooFix.initPathFromAssetsRuntime(Context context, String assetName) ;

/**
 * 从指定目录加载补丁
 * @param context
 * @param dexPath
 */ 
RocooFix.applyPatchRuntime(Context context, String dexPath)  ;


/**
 *  
 *  new Feature  beta 中
 * 从指定目录加载so补丁,使用so还需调用System.loadLibrary("xx")
 * @param context
 * @param soDirPath  so补丁路径(这里是dir)
 */ 
 RocooSoFix.applyPatch(Context context, String soDirPath);

Configuration

1 在root的build.gradle增加如下内容:

 repositories {
        jcenter()
    }
 dependencies {
        classpath 'com.dodola:rocoofix:1.2.6’
    }

2 在你项目的build.gradle文件里添加如下配置

apply plugin: 'com.dodola.rocoofix'

repositories {
    jcenter()
}

rocoo_fix {
    includePackage = ['com/dodola/rocoosample']//指定将来可能需要制作补丁的package(就是指定插庄的范围)
    excludeClass = ['BaseApplication.class']//将不需要加到patch里的类写在这里(不需要插庄的类)
    
    preVersionPath = '1'//注意:此项属性只在需要制作补丁的时候才需开启!!如果不需要制作补丁则需要去掉此项
    
    enable = true//注意:关掉此项会无法生成Hash.txt文件
    
    scanref=true//默认为 false,开启这个选项会将与补丁 class 相引用的 class 都打入包中来解决 ART 虚拟机崩溃问题,功能 Beta 中
}

dependencies {

    compile 'com.dodola:rocoo:1.1'
}

这里主要介绍一下preVersionPath这个属性的作用。

rocoo_fix将制作补丁的步骤透明化,用户无需手动备份hash.txt文件,插件会自动根据当前的versionCode生成hash.txt和mapping.txt文件到指定目录,比如:

上一个版本发布的时候版本号是1,那么生成的文件会放在app源码目录/rocooFix/version1/[debug]|[release]的目录下,如果需要制作补丁那么在配置里指定preVersionPath 属性,它的值是上一个版本的版本号,这里的值是1,

然后将build.gradle的versionCode的号码修改,这里修改成2,只要和之前的版本不同就可以,没有具体值的要求

Proguard(混淆)

-keep class com.dodola.rocoofix.** {*;}
-keep class com.lody.legend.** {*;}
-keepclassmembers class com.dodola.rocoosample.** {
  public <init>();//保留init,和include package保持一致
}

Build Patch

下面演示一下使用项目demo生成补丁的制作过程

1 假如我们需要打补丁的文件是

package com.dodola.rocoosample;

public class HelloHack {

    public String showHello() {
        return "hello world";
    }
}

此时build.gradle里的VersionCode是1 enter description here

2 运行一次应用,这时会在app的目录下生成如下文件:

enter description here

这里可以看做是我们已经发布版本的hash.txt

3 假设我们需要修复步骤1 里的showHello方法,修改如下:

package com.dodola.rocoosample;

public class HelloHack {

    public String showHello() {
        return "hello Hack";//此处修复,补丁加载后该方法返回hello hack
    }
}

4 修改build.gradle 文件里rocoo_fix项,让其执行patch 的task,配置如下

rocoo_fix {

    preVersionPath = '1'//注意:这里指定的是需要打补丁的VersionCode
    enable = true
}

5 修改当前项目的versionCode为2,说明这个是一个升级fix版本。

enter description here

6 正常发布应用,此时会在下图所示的路径中生成补丁文件:

enter description here

7 我们可以反编译apk来确认插庄是否成功

enter description here

相关项目

Legend