sfuhrm/radiobrowser4j

Crashes on Android release minified builds with the following exception

rafsanjani opened this issue · 5 comments

A MultiException has 2 exceptions.  They are:
1. java.lang.NoSuchMethodException: The class DynamicConfigurationServiceImpl has no constructor marked @Inject and no zero argument constructor
2. java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor(
	implementation=org.jvnet.hk2.internal.DynamicConfigurationServiceImpl
	contracts={org.glassfish.hk2.api.DynamicConfigurationService}
	scope=jakarta.inject.Singleton
	qualifiers={}
	descriptorType=CLASS
	descriptorVisibility=LOCAL
	metadata=
	rank=0
	loader=null
	proxiable=null
	proxyForSameScope=null
	analysisName=null
	id=2
	locatorId=0
	identityHashCode=167453374
	reified=false)

Hi,

to me the Android problems also posted by others look like the choice of the project-used Jersey library for HTTP communication does not fit Android so well. So this problem is probably not so easily solvable.

Regarding your problem, the Jersey library and its helpers uses a lot of introspection that will break if minifying Android builds. This means you'll probably need to add exceptions to the classes that are involved in this.

I'm thinking of a new major release with another API compatible approach, but I don't have yet a worked out plan for this.
Anyone wanting to help in this?

Stephan

If you want to give it a try, I have an experimental branch with RestEasy library instead of Jersey here: https://github.com/sfuhrm/radiobrowser4j/tree/RESTEASY

This might solve some problems. It might introduce new problems.
The problem you mentioned is from the Jersey library, so there will be a difference.

Hi @sfuhrm,
issue is not problem with library itself. Android should not have trouble running java libraries.
Problem is with obfuscation/shrinking of the code itself through Proguard.

I'd recommend to add to README part for Android that includes Proguard rules to make it work:
-keep class org.glassfish.hk2.utilities.** { *; } -keep class org.glassfish.jersey.** { *; } -keep class org.jvnet.hk2.internal.** { *; } -keep class de.sfuhrm.radiobrowser4j.** { *; }

@SekyCz thanks for the information, this helps a lot! I am not running this library on Android, so all help is appreciated here.
I'll add your excerpt to the README as proposed :).

Closing since the obfuscation config proposed by @SekyCz seems plausible. Added it to the README.md as proposed.
Thank you very much!