2017-08-22 53 views
1

我檢查一切都在我的調試版本,一切工作正常,但是當我生成簽名的.apk我得到這個錯誤:java.lang.NoSuchMethodException:<init>

java.lang.NoSuchMethodException: <init> [interface org.simpleframework.xml.core.Contact, interface org.simpleframework.xml.Attribute, class org.simpleframework.xml.stream.Format] 
java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [interface org.simpleframework.xml.core.Contact, interface org.simpleframework.xml.Attribute, class org.simpleframework.xml.stream.Format] 
at retrofit2.converter.simplexml.SimpleXmlRequestBodyConverter.convert(SimpleXmlRequestBodyConverter.java:43) 
at retrofit2.converter.simplexml.SimpleXmlRequestBodyConverter.convert(SimpleXmlRequestBodyConverter.java:26) 
at retrofit2.ParameterHandler$Body.apply(ParameterHandler.java:297) 
at retrofit2.ServiceMethod.toRequest(ServiceMethod.java:109) 
at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:178) 
at retrofit2.OkHttpCall.execute(OkHttpCall.java:162) 
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:171) 
at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber$1.request(OperatorSubscribeOn.java:109) 
at rx.Subscriber.setProducer(Subscriber.java:211) 
at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.setProducer(OperatorSubscribeOn.java:105) 
at rx.Subscriber.setProducer(Subscriber.java:205) 
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:152) 
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:138) 
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) 
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) 
at rx.Observable.unsafeSubscribe(Observable.java:10256) 
at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.call(OperatorSubscribeOn.java:100) 
at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:230) 
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:818) 
Caused by: java.lang.NoSuchMethodException: <init> [interface org.simpleframework.xml.core.Contact, interface org.simpleframework.xml.Attribute, class org.simpleframework.xml.stream.Format] 
at java.lang.Class.getConstructor(Class.java:531) 
at java.lang.Class.getConstructor(Class.java:495) 
at org.simpleframework.xml.core.LabelExtractor$LabelBuilder.getConstructor(LabelExtractor.java:426) 

如果我得到它的權利,這是ProGuard的問題,但我不知道如何解決它。有什麼建議嗎?

+1

嘗試https://stackoverflow.com/a/41881633/6834114 – Omi

+0

是的,我已經找到了解決辦法,謝謝: ) – Den

回答

1

好吧,我找到了解決辦法,這個代碼在Proguard.rules:

-keep public class org.simpleframework.**{ *; } 
-keep class org.simpleframework.xml.**{ *; } 
-keep class org.simpleframework.xml.core.**{ *; } 
-keep class org.simpleframework.xml.util.**{ *; }