public class HttpProxy{
public static <T> T getProxy(Class<T> c) {
return (T) Proxy.newProxyInstance(HttpProxy.class.getClassLoader(),
new Class<?>[] { c }, handler);
}
static class HttpInvocationHandler implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
Object obj = null;
try {
throw new CustomException()
}catch (CustomException e) {
//it work here
throw e;
}
return obj;
}
}
}
调用方法:
try{
Res resp = HttpProxy.getProxy(IMODEL.class).login();
if (res != null){
return ok;
}
} catch (CustomException e) {
//after set proguard.config ,its didn't work
Log.e(TAG, Log.getStackTraceString(e));
} catch(Exception e){
//after set proguard.config ,its did here
}
如果我设置了project.properties,我就无法捕获自定义异常。
如果我没有设置project.properties,它可以正常工作。