Meituan-Dianping / Meituan-Dianping/Robust
2019-06-12 17:14:04.876 18797-18797/com.homelink.im W/System.err: java.lang.IllegalArgumentException: method com.homelink.ljpermission.RequestOptions.requestPermissions argument 1 has type java.lang.String[], got java.lang.Object[]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.5k
- Forks
- 806
- PR merge metrics
- No merged PRs in 30d
Description
在提交issue之前,我们应该先查询是否已经有相关的issue和ReadMe中的注意事项,比如说Robust在0.3.3版本才支持windows开发。提交issue时,我们需要写明issue的原因,最好可以携带编译或运行过程的日志或者截图。issue最好以下面的格式提出:
异常类型:app运行时异常/编译异常
手机型号:如:Nexus 5(如是编译异常,则可以不填)
手机系统版本:如:Android 5.0 (如是编译异常,则可以不填)
Robust版本:如:0.4.87
Gradle版本:如:2.10
系统:如:Mac
堆栈/日志:
如是编译异常,请在执行gradle命令时,加上--stacktrace,并把结果重定向,例如在demo中重定向命令如下:./gradlew clean assembleRelease --stacktrace --no-daemon >log.txt ,结果重定向到当前的目录下的log.txt文件;
日志中我们需要过滤"robust"关键字,可以初步查找问题的大概原因;
Robust提供了sample样例与我们的源码,大家在使用前可以先将样例跑通,如遇任何疑问也欢迎大家提出,更鼓励大家给我们提pr,谢谢大家的支持.
bug堆栈信息:
2019-06-12 17:14:04.876 18797-18797/com.xxx.im W/System.err: java.lang.IllegalArgumentException: method com.xxx.ljpermission.RequestOptions.requestPermissions argument 1 has type java.lang.String[], got java.lang.Object[]
报错的方法
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
PushSdkDependencyImpl.IS_DEAD_PUSH = true;
super.onCreate(savedInstanceState);
ToastUtilWrapper.toast("aaaaaaaa");
LjPermissionUtil
.with(this)
.requestPermissions(new String[] {
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
})
.onCallBack(new LjPermissionUtil.PermissionCallBack() {
@Override
public void onPermissionResult(List granted, List denied) {
//如果获取到手机信息读取权限,尝试更新 DeviceId
if (granted.contains(Manifest.permission.READ_PHONE_STATE)) {
DeviceUtil.getDeviceIDEx(getApplicationContext());
}
if (denied == null || denied.size() == 0) {
pageJumpLogic();
} else {
showPermissionDialog(denied);
}
}
}).begin();
}
反编译class
public Object[] getRealParameter(Object[] objArr) {
if (objArr == null || objArr.length < 1) {
return objArr;
}
Object[] objArr2 = new Object[objArr.length];
int i = 0;
while (true) {
int i2 = i;
if (i2 >= objArr.length) {
return objArr2;
}
if (objArr[i2] instanceof Object[]) {
objArr2[i2] = getRealParameter((Object[]) objArr[i2]);
} else if (objArr[i2] == this) {
objArr2[i2] = this.originClass;
} else {
objArr2[i2] = objArr[i2];
}
i = i2 + 1;
}
}
protected void onCreate(Bundle savedInstanceState) {
PushSdkDependencyImpl.IS_DEAD_PUSH = true;
staticRobustonCreate(this, this.originClass, savedInstanceState);
EnhancedRobustUtils.invokeReflectStaticMethod("toast", ToastUtilWrapper.class, getRealParameter(new Object[]{"aaaaaaaa"}), new Class[]{String.class});
Object obj = (RequestOptions) EnhancedRobustUtils.invokeReflectStaticMethod("with", LjPermissionUtil.class, getRealParameter(new Object[]{this}), new Class[]{Activity.class});
String[] strArr = new String[]{"android.permission.READ_PHONE_STATE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"};
if (obj == this) {
obj = ((MainShellActivityPatch) obj).originClass;
}
obj = (RequestOptions) EnhancedRobustUtils.invokeReflectMethod("requestPermissions", obj, getRealParameter(new Object[]{strArr}), new Class[]{String[].class}, RequestOptions.class);
1 1 = (1) EnhancedRobustUtils.invokeReflectConstruct("com.lianjia.alliance.MainShellActivity$1", getRealParameter(new Object[]{this}), new Class[]{MainShellActivity.class});
if (obj == this) {
obj = ((MainShellActivityPatch) obj).originClass;
}
obj = (RequestOptions) EnhancedRobustUtils.invokeReflectMethod("onCallBack", obj, getRealParameter(new Object[]{1}), new Class[]{PermissionCallBack.class}, RequestOptions.class);
if (obj == this) {
obj = ((MainShellActivityPatch) obj).originClass;
}
EnhancedRobustUtils.invokeReflectMethod("begin", obj, new Object[0], null, RequestOptions.class);
}
当我的参数是String数组时, 插入代码后变成了Object数组
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading EnhancedRobustUtils.getRealParameter and its use in invokeReflectMethod for RequestOptions.requestPermissions. Compare the original String[] argument with the decompiled call and trace where its runtime type changes. Done means the permission request accepts the String[] argument after Robust instrumentation without the reported IllegalArgumentException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100