Git Product home page Git Product logo

robust's Introduction

Robust

Download PRs Welcome License

Robust is an Android HotFix solution with high compatibility and high stability. Robust can fix bugs immediately without publishing apk.

中文说明

More help on Wiki

Environment

  • Mac Linux and Windows
  • Gradle 2.10+ , include 3.0
  • Java 1.7 +

Usage

  1. Add below codes in the module's build.gradle.

    apply plugin: 'com.android.application'
    //please uncomment fellow line before you build a patch
    //apply plugin: 'auto-patch-plugin'
    apply plugin: 'robust'
    
    compile 'com.meituan.robust:robust:0.4.99'
  2. Add below codes in the outest project's build.gradle file.

     buildscript {
        repositories {
            jcenter()
        }
        dependencies {
             classpath 'com.meituan.robust:gradle-plugin:0.4.99'
             classpath 'com.meituan.robust:auto-patch-plugin:0.4.99'
       }
    }
  3. There are some configure items in app/robust.xml,such as classes which Robust will insert code,this may diff from projects to projects.Please copy this file to your project.

Advantages

  • Support 2.3 to 10 Android OS
  • Perfect compatibility
  • Patch takes effect without a reboot
  • Support fixing at method level,including static methods
  • Support add classes and methods
  • Support ProGuard,including inline methods or changing methods' signature

When you build APK,you may need to save "mapping.txt" and the files in directory "build/outputs/robust/".

AutoPatch

AutoPatch will generate patch for Robust automatically. You just need to fellow below steps to genrate patches. For more details please visit website http://tech.meituan.com/android_autopatch.html

Steps

  1. Put 'auto-patch-plugin' just behind 'com.android.application',but in the front of others plugins。like this:

     apply plugin: 'com.android.application'
     apply plugin: 'auto-patch-plugin'
  2. Put mapping.txt and methodsMap.robust which are generated when you build the apks in diretory app/robust/,if not exists ,create it!

  3. After modifying the code ,please put annotation @Modify on the modified methods or invoke RobustModify.modify() (designed for Lambda Expression )in the modified methods:

       @Modify
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
         }
         //
         protected void onCreate(Bundle savedInstanceState) {
            RobustModify.modify()
            super.onCreate(savedInstanceState);
         }
         

    Use annotation @Add when you neeed to add methods or classes.

        //add method
        @Add
        public String getString() {
            return "Robust";
        }
        
        //add class
        
        @Add
        public class NewAddCLass {
            public static String get() {
               return "robust";
             }
        }
  4. After those steps,you need to run the same gradle command as you build the apk,then you will get patches in directory app/build/outputs/robust/patch.jar.

  5. Generating patches always end like this,which means patches is done Success in generating patch

Demo Usage

  1. Excute fellow command to build apk:

    ./gradlew clean  assembleRelease --stacktrace --no-daemon
  2. After install apk on your phone,you need to save mapping.txt and app/build/outputs/robust/methodsMap.robust

  3. Put mapping.txt and methodsMap.robust which are generated when you build the apks into diretory app/robust/,if directory not exists ,create it!

  4. After modifying the code ,please put annotation @Modify on the modified methods or invoke RobustModify.modify() (designed for Lambda Expression )in the modified methods.

  5. Run the same gradle command as you build the apk:

    ./gradlew clean  assembleRelease --stacktrace --no-daemon
  6. Generating patches always end like this,which means patches is done Success in generating patch

  7. Copy patch to your phone:

    adb push ~/Desktop/code/robust/app/build/outputs/robust/patch.jar /sdcard/robust/patch.jar

    patch directory can be configured in PatchManipulateImp.

  8. Open app,and click Patch button,patch is used.

  9. Also you can use our sample patch in app/robust/sample_patch.jar ,this dex change text after you click Jump_second_Activity Button.

  10. In the demo ,we change the text showed on the second activity which is configured in the method getTextInfo(String meituan) in class SecondActivity

Attentions

  1. You should modify inner classes' private constructors to public modifier.

  2. AutoPatch cannot handle situations which method returns this,you may need to wrap it like belows:

    method a(){
      return this;
    }

    changed to

    method a(){
      return new B().setThis(this).getThis();
    }
  3. Not Support add fields,but you can add classes currently, this feature is under testing.

  4. Classes added in patch should be static nested classes or non-inner classes,and all fields and methods in added class should be public.

  5. Support to fix bugs in constructors currently is under testing.

  6. Not support methods which only use fields,without method call or new expression.

  7. Support to resources and so file is under testing.

  8. For more help, please visit Wiki

License

Copyright 2017 Meituan-Dianping

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

robust's People

Contributors

achellies avatar hedex avatar limengyun2008 avatar mivanzhang avatar w4lle avatar xyczero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robust's Issues

为什么这个补丁没有生效?

2017-03-30 20:43:52,094 - [DEBUG::robust.b::XXX.robust.b] - robustApkHash = 41072e00c519d9000afda9c5b0a60bb5
2017-03-30 20:43:52,099 - [DEBUG::robust.b::XXX.robust.b] - lcoalPath = /storage/emulated/0/XXX/app120/patch.dex
2017-03-30 20:43:52,099 - [DEBUG::XXX.robust.b::XXX.robust.b] - tmpPath = /storage/emulated/0/XXX/app120/patch
2017-03-30 20:43:52,100 - [DEBUG::XXX.robust.b::XXX.robust.b] - AppHash = null
2017-03-30 20:43:52,100 - [DEBUG::XXX.robust.b::XXX.robust.b] - LocalPath = /storage/emulated/0/XXX/app120/patch.dex.jar
2017-03-30 20:43:52,100 - [DEBUG::XXX.robust.b::XXX.robust.b] - Md5 = null
2017-03-30 20:43:52,100 - [DEBUG::v.robust.b::XXX.robust.b] - Name = 3.4.0
2017-03-30 20:43:52,101 - [DEBUG::XXX.robust.b::XXX.robust.b] - PatchesInfoImplClassFullName = com.meituan.robust.patch.PatchesnfoImpl
2017-03-30 20:43:52,101 - [DEBUG::XXX.robust.b::XXX.robust.b] - TempPath = /storage/emulated/0/XXX/app120/patch_temp.jar
2017-03-30 20:43:52,101 - [DEBUG::XXX.robust.b::XXX.robust.b] - Url = null
2017-03-30 20:43:52,102 - [DEBUG::XXX.robust.a::XXX.robust.a] - robust arrived in exceptionNotify
2017-03-30 20:43:52,105 - [DEBUG::XXX.robust.a::XXX.robust.a] - robust arrived in logNotify
2017-03-30 20:43:52,105 - [DEBUG::XXX.robust.a::XXX.robust.a] - robust arrived in onPatchApplied

这是我后台输出的关于patch.jar的相关信息 请问为什么补丁没有生效?
修复的是activity的oncreate()方法 在该方法中添加了一个Toast

methodsMap.robust文件生成失败或不稳定?

用官方的demo编译运行打一个包,查看outputs目录 ,第一次可以看到生成的methodsMap.robust文件,后面尝试手动干掉这个outputs目录,再次打包,不会自动生成methodsMap.robust文件。

Issue/提问须知

在提交issue之前,我们应该先查询是否已经有相关的issue和ReadMe中的注意事项,比如说Robust在0.3.2版本才支持windows开发。提交issue时,我们需要写明issue的原因,最好可以携带编译或运行过程的日志或者截图。issue最好以下面的格式提出:

异常类型:app运行时异常/编译异常

手机型号:如:Nexus 5(如是编译异常,则可以不填)

手机系统版本:如:Android 5.0 (如是编译异常,则可以不填)

Robust版本:如:0.3.2

Gradle版本:如:2.10

系统:如:Mac

堆栈/日志:

  1. 如是编译异常,请在执行gradle命令时,加上--stacktrace,并把结果重定向,例如在demo中重定向命令如下:./gradlew clean assembleRelease --stacktrace --no-daemon >log.txt ,结果重定向到当前的目录下的log.txt文件;
  2. 日志中我们需要过滤"robust"关键字,可以初步查找问题的大概原因;

patch失败啊

/com.meituan.robust.sample E/robust: PatchsInfoImpl failed,cause ofjava.lang.ClassNotFoundException: Didn't find class "com.meituan.robust.patch.PatchesInfoImpl" on path: DexPathList[[zip file "/storage/emulated/0/robust/patch_temp.jar"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]

报这样的错误啊,在patch的时候,用的是sample例子,然后不管是debug还是release,都提示这个。可以确定得是patch.jar包中是存在com.meituan.robust.patch.PatchesInfoImpl这个的。这个jar文件也是可以确定放到正确路径下的,我是一步一步调试的,到patchsInfoClass = classLoader.loadClass(patch.getPatchesInfoImplClassFullName());这一句就抛异常了。你们在弄自己的工程时,难道没有出息类似的情况吗?

ReadMe中英文翻译不一致

4.Classes added in patch should not be non-static methods ,and all fields and methods in added class should be public.

  1. 新增加的类不能是非静态内部类(静态的内部类可以),新增类中的方法和字段需要全部都是public的

maven 仓库无法访问

Could not resolve com.meituan.gradle.mtsign:mtsign:0.0.1.
         > Could not get resource 'http://depot.sankuai.com/nexus/content/groups/public/com/meituan/gradle/mtsign/mtsign/0.0.1/mtsign-0.0.1.pom'.
            > Could not GET 'http://depot.sankuai.com/nexus/content/groups/public/com/meituan/gradle/mtsign/mtsign/0.0.1/mtsign-0.0.1.pom'.
               > depot.sankuai.com: nodename nor servname provided, or not known

http://depot.sankuai.com/nexus/content/groups/public 这个仓库无法访问,是你们公司内部的?

成功打好补丁后遇到的异常

异常类型:clean project 出现

手机型号:如:huawei s8-701w

手机系统版本:如:Android 4.3

Robust版本:如:0.3.2

Gradle版本:如:2.10

系统:如:Windows

!!备注:什么时候有热修复下发给用户应用的补丁平台或者服务呢?(期待解答)!
如果自己实现下发补丁给用户应用,该怎么做呢?

1

补丁方法为空

依据提供的步骤配置,编译报错,参考demo没看出有啥不同。

Error:Execution failed for task ':app:transformClassesWithAutoPatchTransformForRelease'.

patch method is empty ,please check your Modify annotation or use RobustModify.modify() to mark modified methods

补丁生效咨询

Robust版本:0.3.2
Gradle版本:2.14.1
系统:Mac
Hi,我这边尝试了demo,有些困惑的地方需要咨询一下。我把补丁文件push到sdcard,点击patch之后补丁会生效。如果杀死app,重新进入重新点击patch,补丁不生效。看了源码发现在PatchExecutor类中的patch方法中会删除补丁文件。想了解这么处理的原因是什么?每次都需要从localFile 处理到tempFile么

mapping.txt 文件怎么生成?

配置都按照文档写的,robust.xml直接复制的demo中的,仅仅改动了hotfixPackage的包名和patchPackname的名字
build.grade 文件中加入
apply plugin: 'com.android.application'
//制作补丁时将这个打开,auto-patch-plugin紧跟着com.android.application
//apply plugin: 'auto-patch-plugin'
apply plugin: 'robust'

不知道是什么原因导致mapping.txt 生成不了,请大家指点一下!!!!!!!!!!!!!

windows下,版本0.3.1项目打包出错

还未开启apply plugin: 'auto-patch-plugin'的时候,执行gradlew clean assembleRelease --stacktrace --no-daemon,报的错
================robust start================
:app:transformClassesWithRobustForRelease FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformClassesWithRobustForRelease'.

No such property: Matcher for class: robust.gradle.plugin.ConvertUtils

Build Failed --> something wrong when readAnnotation, cannot find android\support....

请问下,生成补丁的时候,提示如下,要肿么办。我照着demo看了好几遍了,不知道哪里搞错了。

To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html.
Register robust transform successful !!!
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72421Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2421Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2421Library UP-TO-DATE
:app:prepareComMeituanRobustRobust030Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:mergeReleaseShaders
:app:compileReleaseShaders
:app:generateReleaseAssets
:app:mergeReleaseAssets
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:incrementalReleaseJavaCompilationSafeguard
:app:compileReleaseJavaWithJavac
:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:lintVitalRelease
:app:prePackageMarkerForRelease
:app:transformClassesWithAutoPatchTransformForRelease
================autoPatch start================
autopatch read all class file cost 0.09 second
check all class cost 0.229 second, class count: 2350
something wrong when readAnnotation, cannot find android\support\design\R$anim: android.support.design.R$anim found in android\support\design\R$anim.class cannot find class name android\support\design\R$anim
something wrong when readAnnotation, cannot find android\support\design\R$attr: android.support.design.R$attr found in android\support\design\R$attr.class cannot find class name android\support\design\R$attr
something wrong when readAnnotation, cannot find android\support\design\R$bool: android.support.design.R$bool found in android\support\design\R$bool.class cannot find class name android\support\design\R$bool
something wrong when readAnnotation, cannot find android\support\design\R$color: android.support.design.R$color found in android\support\design\R$color.class cannot find class name android\support\design\R$color
something wrong when readAnnotation, cannot find android\support\design\R$dimen: android.support.design.R$dimen found in android\support\design\R$dimen.class cannot find class name android\support\design\R$dimen
something wrong when readAnnotation, cannot find android\support\design\R$drawable: android.support.design.R$drawable found in android\support\design\R$drawable.class cannot find class name android\support\design\R$drawable
something wrong when readAnnotation, cannot find android\support\design\R$id: android.support.design.R$id found in android\support\design\R$id.class cannot find class name android\support\design\R$id
something wrong when readAnnotation, cannot find android\support\design\R$integer: android.support.design.R$integer found in android\support\design\R$integer.class cannot find class name android\support\design\R$integer
something wrong when readAnnotation, cannot find android\support\design\R$layout: android.support.design.R$layout found in android\support\design\R$layout.class cannot find class name android\support\design\R$layout
something wrong when readAnnotation, cannot find android\support\design\R$string: android.support.design.R$string found in android\support\design\R$string.class cannot find class name android\support\design\R$string
something wrong when readAnnotation, cannot find android\support\design\R$style: android.support.design.R$style found in android\support\design\R$style.class cannot find class name android\support\design\R$style
something wrong when readAnnotation, cannot find android\support\design\R$styleable: android.support.design.R$styleable found in android\support\design\R$styleable.class cannot find class name android\support\design\R$styleable
something wrong when readAnnotation, cannot find android\support\design\R: android.support.design.R found in android\support\design\R.class cannot find class name android\support\design\R
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$anim: android.support.v7.appcompat.R$anim found in android\support\v7\appcompat\R$anim.class cannot find class name android\support\v7\appcompat\R$anim
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$attr: android.support.v7.appcompat.R$attr found in android\support\v7\appcompat\R$attr.class cannot find class name android\support\v7\appcompat\R$attr
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$bool: android.support.v7.appcompat.R$bool found in android\support\v7\appcompat\R$bool.class cannot find class name android\support\v7\appcompat\R$bool
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$color: android.support.v7.appcompat.R$color found in android\support\v7\appcompat\R$color.class cannot find class name android\support\v7\appcompat\R$color
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$dimen: android.support.v7.appcompat.R$dimen found in android\support\v7\appcompat\R$dimen.class cannot find class name android\support\v7\appcompat\R$dimen
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$drawable: android.support.v7.appcompat.R$drawable found in android\support\v7\appcompat\R$drawable.class cannot find class name android\support\v7\appcompat\R$drawable
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$id: android.support.v7.appcompat.R$id found in android\support\v7\appcompat\R$id.class cannot find class name android\support\v7\appcompat\R$id
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$integer: android.support.v7.appcompat.R$integer found in android\support\v7\appcompat\R$integer.class cannot find class name android\support\v7\appcompat\R$integer
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$layout: android.support.v7.appcompat.R$layout found in android\support\v7\appcompat\R$layout.class cannot find class name android\support\v7\appcompat\R$layout
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$string: android.support.v7.appcompat.R$string found in android\support\v7\appcompat\R$string.class cannot find class name android\support\v7\appcompat\R$string
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$style: android.support.v7.appcompat.R$style found in android\support\v7\appcompat\R$style.class cannot find class name android\support\v7\appcompat\R$style
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R$styleable: android.support.v7.appcompat.R$styleable found in android\support\v7\appcompat\R$styleable.class cannot find class name android\support\v7\appcompat\R$styleable
something wrong when readAnnotation, cannot find android\support\v7\appcompat\R: android.support.v7.appcompat.R found in android\support\v7\appcompat\R.class cannot find class name android\support\v7\appcompat\R
something wrong when readAnnotation, cannot find android\support\v7\recyclerview\R$attr: android.support.v7.recyclerview.R$attr found in android\support\v7\recyclerview\R$attr.class cannot find class name android\support\v7\recyclerview\R$attr
something wrong when readAnnotation, cannot find android\support\v7\recyclerview\R$dimen: android.support.v7.recyclerview.R$dimen found in android\support\v7\recyclerview\R$dimen.class cannot find class name android\support\v7\recyclerview\R$dimen
something wrong when readAnnotation, cannot find android\support\v7\recyclerview\R$id: android.support.v7.recyclerview.R$id found in android\support\v7\recyclerview\R$id.class cannot find class name android\support\v7\recyclerview\R$id
something wrong when readAnnotation, cannot find android\support\v7\recyclerview\R$styleable: android.support.v7.recyclerview.R$styleable found in android\support\v7\recyclerview\R$styleable.class cannot find class name android\support\v7\recyclerview\R$styleable
something wrong when readAnnotation, cannot find android\support\v7\recyclerview\R: android.support.v7.recyclerview.R found in android\support\v7\recyclerview\R.class cannot find class name android\support\v7\recyclerview\R
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\BuildConfig: com.nanyi545.www.testrobust.BuildConfig found in com\nanyi545\www\testrobust\BuildConfig.class cannot find class name com\nanyi545\www\testrobust\BuildConfig
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\MainActivity: com.nanyi545.www.testrobust.MainActivity found in com\nanyi545\www\testrobust\MainActivity.class cannot find class name com\nanyi545\www\testrobust\MainActivity
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$anim: com.nanyi545.www.testrobust.R$anim found in com\nanyi545\www\testrobust\R$anim.class cannot find class name com\nanyi545\www\testrobust\R$anim
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$attr: com.nanyi545.www.testrobust.R$attr found in com\nanyi545\www\testrobust\R$attr.class cannot find class name com\nanyi545\www\testrobust\R$attr
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$bool: com.nanyi545.www.testrobust.R$bool found in com\nanyi545\www\testrobust\R$bool.class cannot find class name com\nanyi545\www\testrobust\R$bool
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$color: com.nanyi545.www.testrobust.R$color found in com\nanyi545\www\testrobust\R$color.class cannot find class name com\nanyi545\www\testrobust\R$color
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$dimen: com.nanyi545.www.testrobust.R$dimen found in com\nanyi545\www\testrobust\R$dimen.class cannot find class name com\nanyi545\www\testrobust\R$dimen
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$drawable: com.nanyi545.www.testrobust.R$drawable found in com\nanyi545\www\testrobust\R$drawable.class cannot find class name com\nanyi545\www\testrobust\R$drawable
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$id: com.nanyi545.www.testrobust.R$id found in com\nanyi545\www\testrobust\R$id.class cannot find class name com\nanyi545\www\testrobust\R$id
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$integer: com.nanyi545.www.testrobust.R$integer found in com\nanyi545\www\testrobust\R$integer.class cannot find class name com\nanyi545\www\testrobust\R$integer
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$layout: com.nanyi545.www.testrobust.R$layout found in com\nanyi545\www\testrobust\R$layout.class cannot find class name com\nanyi545\www\testrobust\R$layout
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$mipmap: com.nanyi545.www.testrobust.R$mipmap found in com\nanyi545\www\testrobust\R$mipmap.class cannot find class name com\nanyi545\www\testrobust\R$mipmap
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$string: com.nanyi545.www.testrobust.R$string found in com\nanyi545\www\testrobust\R$string.class cannot find class name com\nanyi545\www\testrobust\R$string
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$style: com.nanyi545.www.testrobust.R$style found in com\nanyi545\www\testrobust\R$style.class cannot find class name com\nanyi545\www\testrobust\R$style
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R$styleable: com.nanyi545.www.testrobust.R$styleable found in com\nanyi545\www\testrobust\R$styleable.class cannot find class name com\nanyi545\www\testrobust\R$styleable
something wrong when readAnnotation, cannot find com\nanyi545\www\testrobust\R: com.nanyi545.www.testrobust.R found in com\nanyi545\www\testrobust\R.class cannot find class name com\nanyi545\www\testrobust\R
new add methods list is

new add classes list is

patchMethodSignureSet is printed below

:app:transformClassesWithAutoPatchTransformForRelease FAILED

BUILD FAILED

Total time: 16.404 secs

---------------------代码---------------------

生成补丁之前 :
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

生成补丁的时候
@modify
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Object a=new Object();
Log.i("sss","--patching--:"+a);
}

------------proguard 和demo一样-------------------------

-keep class meituan.robust.patch.**{*;}

-keep class com.google.gson.{*;}
-keep class com.meituan.robust.
{*;}
-dontwarn
-keepattributes Signature,SourceFile,LineNumberTable
-keepattributes Annotation
-keeppackagenames
-ignorewarnings
-dontwarn android.support.v4.**,CompatHoneycomb,com.tenpay.android.
-optimizations !class/unboxing/enum,!code/simplification/arithmetic

------------------- gradle 2.1 + buildToolsVersion "24.0.2"+ AS 2.3 ------------------------

--------------------gradle 补丁也放在第二个了-------------------------
apply plugin: 'com.android.application'
apply plugin: 'auto-patch-plugin'
apply plugin: 'robust'

-----------------------robust.xml和demo一样 只是修改了hotfixPackage为自己的包名。 -----------------------

<switch>
    <!--true代表打开Robust,这个会比较耗时建议release包在打开-->
    <turnOnRobust>true</turnOnRobust>
    <!--<turnOnRobust>false</turnOnRobust>-->

    <!--是否开启手动模式,手动模式会去寻找配置项patchPackname包名下的所有类,自动的处理混淆,然后把patchPackname包名下的所有类制作成补丁-->
    <!--<manual>true</manual>-->
    <manual>false</manual>

    <!--是否强制插入插入代码,Robust默认在debug模式下是关闭的,开启这个选项为true会在debug下插入代码-->
    <!--<forceInsert>true</forceInsert>-->
    <forceInsert>false</forceInsert>

    <!--是否捕获补丁中所有反射的异常,建议上线的时候这个开关的值为true,测试的时候为false-->
    <catchReflectException>true</catchReflectException>
    <!--<catchReflectException>false</catchReflectException>-->

    <!--是否在补丁加上log,建议上线的时候这个开关的值为false,测试的时候为true-->
    <!--<patchLog>true</patchLog>-->
    <patchLog>false</patchLog>
</switch>

<!--需要热补的包名或者类名,这些包名下的所有类都被会插入代码-->
<packname name="hotfixPackage">
    <name>com.nanyi545.www.testrobust</name>
</packname>

<!--不需要热补的包名或者类名,可以在需要热补的包中剔除指定的类或者包-->
<exceptPackname name="exceptPackage">
    <name>com.meituan.robust</name>
</exceptPackname>

<!--补丁的包名-->
<patchPackname name="patchPackname">
    <name>com.meituan.robust.patch</name>
</patchPackname>

<!--自动化补丁中,不需要反射处理的类,这个配置项慎重选择-->
<noNeedReflectClass name="classes no need to reflect">

</noNeedReflectClass>

手动模式为false情况下 patchPackname 是不是不用管。。应该没有影响吧。。

patch.jar无法加载

/**

  • Created by mivanzhang on 17/2/27.
    */

public class PatchManipulateImp extends PatchManipulate {
@OverRide
protected List fetchPatchList(Context context) {
//将app自己的robustApkHash上报给服务端,服务端根据robustApkHash来区分每一次apk build来给app下发补丁
//String robustApkHash = RobustApkHashUtils.readRobustApkHash(context);
Patch patch = new Patch();
patch.setName("123");
patch.setLocalPath(Environment.getExternalStorageDirectory().getPath()+ File.separator+"robust"+File.separator + "patch.dex");
patch.setTempPath(Environment.getExternalStorageDirectory().getPath()+ File.separator+"robust"+File.separator + "patch");
patch.setPatchesInfoImplClassFullName("com.meituan.robust.patch.PatchesInfoImpl");
List patches = new ArrayList();
patches.add(patch);
return patches;
}
上述中的patch.setPatchesInfoImplClassFullName中设置的是一个继承patcesInfo的类吗?我在sample和你们的文章中都没有看到此类(继承的话应该如何处理?),现在加载patch.jar时老是报exceptionNotifyDidn't find class "com.meituan.robust.patch.PatchesInfoImpl" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]] whereclass:PatchExecutor method:patch line:108

求解呀!

一直提示patch method is empty,和robust.xml有关系吗?

@OverRide
@modify
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.load).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new PatchExecutor(getApplicationContext(), new PatchManipulateImp(),  new CallBack()).start();
        }
    });

    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(MainActivity.this, Hello(), Toast.LENGTH_SHORT).show();
            Toast.makeText(MainActivity.this, Hello("test"), Toast.LENGTH_SHORT).show();
        }
    });
}

@Modify
public String Hello(){
    return "Hello World! Hello";
}

@Add
public String Hello(String name){
    return "Hello"+name;
}

java.lang.RuntimeException: patch method is empty ,please check your Modify annotation or use RobustModify.modify() to mark modified methods
at robust.gradle.plugin.AutoPatchTransform.autoPatch(AutoPatchTransform.groovy:141)
at robust.gradle.plugin.AutoPatchTransform$autoPatch.callCurrent(Unknown Source)
at robust.gradle.plugin.AutoPatchTransform.transform(AutoPatchTransform.groovy:100)
at com.android.build.api.transform.Transform.transform(Transform.java:290)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:185)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:181)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:176)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)

小白问

robust修复可以添加新类吗?

占领一楼

去年就看到了你们的文章,终于开源了

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.

outDir E:\as-demo\LeakcanaryDemo\app\build\intermediates\transforms\robust\release\folders\1\1f\main:app:processReleaseJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForRelease
:app:transformClassesAndResourcesWithProguardForRelease
ProGuard, version 5.3.2
Reading input...
Reading program directory [E:\as-demo\LeakcanaryDemo\app\build\intermediates\transforms\robust\release\folders\1\1f\main] (filtered)
Reading library jar [D:\Android\Android\sdk\platforms\android-25\android.jar]
Reading library jar [D:\Android\Android\sdk\platforms\android-25\optional\org.apache.http.legacy.jar]
Note: duplicate definition of library class [android.net.http.HttpResponseCache]
Note: duplicate definition of library class [android.net.http.SslCertificate$DName]
Note: duplicate definition of library class [android.net.http.SslError]
Note: duplicate definition of library class [android.net.http.SslCertificate]
Note: duplicate definition of library class [org.apache.http.params.CoreConnectionPNames]
Note: duplicate definition of library class [org.apache.http.params.HttpConnectionParams]
Note: duplicate definition of library class [org.apache.http.params.HttpParams]
Note: duplicate definition of library class [org.apache.http.conn.scheme.SocketFactory]
Note: duplicate definition of library class [org.apache.http.conn.scheme.LayeredSocketFactory]
Note: duplicate definition of library class [org.apache.http.conn.scheme.HostNameResolver]
Note: duplicate definition of library class [org.apache.http.conn.ConnectTimeoutException]
Note: there were 11 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Initializing...
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Note: com.google.gson.internal.UnsafeAllocator: can't find dynamically referenced class sun.misc.Unsafe
Note: com.squareup.okhttp.internal.Platform: can't find dynamically referenced class com.android.org.conscrypt.OpenSSLSocketImpl
Note: com.squareup.okhttp.internal.Platform: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl
Note: com.google.gson.internal.UnsafeAllocator accesses a declared field 'theUnsafe' dynamically
Note: there were 3 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 1 accesses to class members by means of introspection.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Warning: there were 14 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED

patch method is empty

Caused by: java.lang.RuntimeException: patch method is empty ,please check your Modify annotation or use RobustModify.modify() to mark modified methods

并不能生成mapping.txt

新创建了一个项目,把robust集成进去assembleRelease并没有生成mapping.txt。
Win7 x64

为什么美哟mapping.txt文件呢

如题,gradlew clean assembleRelease --stacktrace --no-daemon之后 , 在outputs文件夹下面并没有mapping文件夹,更没有找到mapping.txt文件 , 是我release的方式不对么?? 求解答

生成补丁时候提示如下异常

Caused by: java.lang.RuntimeException: patch method is empty ,please check your Modify annotation or use RobustModify.modify() to mark modified methods

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.