2

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?

2
  • 1
    try stackoverflow.com/a/41881633/6834114 Commented Aug 22, 2017 at 8:27
  • Yes, I already found the solution, thanks :) Commented Aug 22, 2017 at 8:45

2 Answers 2

10

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.**{ *; }
Sign up to request clarification or add additional context in comments.

1 Comment

you save my day ! :)
2

As a point on Den's answer:
it may be enough to specify

-keep class org.simpleframework.xml.**{ *; }

without the rest 3 lines from the original answer.

According to the ProGuard manual:

** matches any part of a class name, possibly containing any number of package separators. For example, **.Test matches all Test classes in all packages except the root package. Or, com.example.** matches all classes in "com.example" and in its subpackages.

Proposed solution may not cover the same set of cases since it doesn't include public classes in the package (that is one level higher) covered by -keep public class org.simpleframework.**{ *; } (from the original answer).

However, in the 1st line of the provided stack trace there are only classes from org.simpleframework.xml... package, not from the higher-level package.

Having similar problem:

java.lang.NoSuchMethodException: <init> [
interface org.simpleframework.xml.core.Contact, 
interface org.simpleframework.xml.ElementMap, 
class org.simpleframework.xml.stream.Format]

I solved it by adding just one line to ProGuard rules.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.