2016-03-28 5 views
1

有効にしたときに呼び出されませんここにSerializableHttpCookie cがあります小娘は:のreadObject関数は、私がAndroidアプリのためPersistentCookieStoreを作るProGuardの

public class SerializableHttpCookie implements Serializable { 
    private static final long serialVersionUID = 6374381323722046732L; 

    private transient final HttpCookie cookie; 
    private transient HttpCookie clientCookie; 

    public SerializableHttpCookie(HttpCookie cookie) { 
     this.cookie = cookie; 
    } 

    public HttpCookie getCookie() { 
     HttpCookie bestCookie = cookie; 
     if (clientCookie != null) { 
      bestCookie = clientCookie; 
     } 
     return bestCookie; 
    } 

    private void writeObject(ObjectOutputStream out) throws IOException { 
     out.writeObject(cookie.getName()); 
     out.writeObject(cookie.getValue()); 
     out.writeObject(cookie.getComment()); 
     out.writeObject(cookie.getCommentURL()); 
     out.writeObject(cookie.getDomain()); 
     out.writeLong(cookie.getMaxAge()); 
     out.writeObject(cookie.getPath()); 
     out.writeObject(cookie.getPortlist()); 
     out.writeInt(cookie.getVersion()); 
     out.writeBoolean(cookie.getSecure()); 
     out.writeBoolean(cookie.getDiscard()); 
    } 

    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 
     String name = (String) in.readObject(); 
     String value = (String) in.readObject(); 
     clientCookie = new HttpCookie(name, value); 
     clientCookie.setComment((String) in.readObject()); 
     clientCookie.setCommentURL((String) in.readObject()); 
     clientCookie.setDomain((String) in.readObject()); 
     clientCookie.setMaxAge(in.readLong()); 
     clientCookie.setPath((String) in.readObject()); 
     clientCookie.setPortlist((String) in.readObject()); 
     clientCookie.setVersion(in.readInt()); 
     clientCookie.setSecure(in.readBoolean()); 
     clientCookie.setDiscard(in.readBoolean()); 
    } 
} 

すべてが良く見えるデバッグ、readObjectは、コールされるようにclientCookie nullではない、decodeCookieリターンnullではないが、私はProGuardのを有効にしたとき、私はコールの後readClassDescriptorreadObjectが呼び出されないことがわかります。したがって、decodeCookieはnullを返します。

このバグを修正するのを手伝ってください。

-keepnames class * implements java.io.Serializable 
-keepclassmembers class * implements java.io.Serializable { 
    static final long serialVersionUID; 
    private static final java.io.ObjectStreamField[] serialPersistentFields; 
    !static !transient <fields>; 
    private void writeObject(java.io.ObjectOutputStream); 
    private void readObject(java.io.ObjectInputStream); 
    java.lang.Object writeReplace(); 
    java.lang.Object readResolve(); 
} 

をProGuardのに:

答えて

2

を追加してください。

関連する問題