android无法捕获Invoke引发的自定义异常

时间:2015-01-05 07:31:13

标签: android proguard

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,它可以正常工作。

像这样obfuscation with proguard vs. java.lang.reflect.Proxy

0 个答案:

没有答案