Search code examples
javaandroidnosuchmethoderror

java.lang.NoSuchMethodException: <init>


I checked everything on my debug build and everything works fine, but when I generate Signed Apk I get this error:

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)

If I get it right this is the ProGuard problem, but I don't know how to fix it. Any advices please?


Solution

  • Okay, I found the solution, this code in the Proguard.rules:

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