-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android related questions #14
Comments
Update I change version to 2.0.5 (first android support) and library worked. Thanks and have a great day. |
Thanks for the issue! I guess the Android environment needs a different approach. |
Yeah, you are right. 2.0.5 work no smoothly (have a different bug) but not bad as 2.2.4 Am I open another issue for this (different bug) or wait you for another release ? |
Well, this seems to be a more conceptual problem of the library that needs to be worked out, not a simple bug :-(. As noted in other issues before, it could be possible to get around the ClassNotFoundException if you take the not-found classes out of the Android-build typical obfuscation (see #13 ). Take a look here: https://developer.android.com/studio/build/shrink-code#keep-code |
Yeah, but I work in debug project and not implement proguard or shrink code etc. But I will try and share result in this thread. Other bug, just list map bug, duplicated key problem. It's nothing compare with that and also just exception when try to get country list. I can still use library in 2.0.5 version and It's seem to be fine for me. |
"Provider for jakarta.ws.rs.client.ClientBuilder cannot be found" looks like there are some |
Hi again, I try your advice but I think nothing change.
or maybe I do wrong way, I am not familiar with packagingOptions blocks. |
Excludes is the opposite you're wanting:
I am not used to the resources packaging options myself, sorry. |
Yeah, I try all tags for packagingOptions and no result. Maybe, some of people can guide us. Until that day, I will continue with old library I think. |
I tried to use 2.2.4. Does not work with the same Provider not found problem. com.fasterxml.jackson.core.JsonFactory |
I am having the same issue. Even with a simple sample application in Android. I am not an expert on gradle, pro-guard, etc. I think best is you download it an try to find out what the problem is. |
@mraalex thanks for the archive ... I'm not managing to import it to Android Studio, it is saying "Error: Module not specified". Is there a way to provide a example without another subproject which seems to confuse gradle / android studio? Anyone having a quick hint? |
Tap on "Build Variants" on the left and make sure that Module:app is set on the debug version: playStoreFreeDebug I am using: If it still does not work you can also create a new project with your Android Studio, integrate the code and see if it is running on your side. Then send me the project. |
The Android mystery is solved, thanks to your help, guys! Thanks @mraalex and all other guys for the suggestions. There needs to be some tweaking to make it run on Android. I am listing them in the following link: https://github.com/sfuhrm/radiobrowser4j/blob/master/ANDROID.md DemoA demo printing radio stations to a full-screen-view is given in the following TAR ball: |
Just came across these same issues with de.sfuhrm:radiobrowser4j:2.5.0 The "fix" relies on turning off codee shrink, minifyEnabled false My app now bloats to over 2x the size :-( Is there a way to use this library without turning off minify ? |
I had no minify enabled. The solution from shuhrm worked for me, even with minify. |
Hmm, interesting, as the demo app linked above has minifyEnabled false, and yes it does build (using both 2.2.5 and 2.5.0), however Proguard is doing very little. if you set minifyEnabled true, it will fail to build. Adding the suggested warnings ignores to proguard-rules.pro it will then build, however using signed release builds will result in runtime crashes. Adding the suggested keep classes, brings in even more warnings to exclude, and at this point, it's quite a away from looking like it can compile. Wondering if anyone has a working Proguard they can share for someone that's using minifyEnabled true |
I have tested my signed release build. It works fine with minifyEnabled. Pro-Guard: build.gradle: android.packagingOptions.resources.excludes += "/*.md" code: |
Is that the app linked above? #14 (comment) |
no. It is from another project. Did you try the official sample project from the readme for Android? |
Using the project in comment #14 (which has all the suggested changes in this thread), both the minified and regular builds will compile, however the minified build crashes when launched. Process: com.changemystyle.gentlewakeup, PID: 26798 The only change I made was to change minifyEnabled true |
This is where I am, using the exact same config. Missing class jakarta.validation.MessageInterpolator$Context (referenced from: void org.glassfish.hk2.utilities.general.internal.MessageInterpolatorImpl$ContextResourceBundle.(jakarta.validation.MessageInterpolator$Context, java.util.Locale) and 2 other contexts) |
You are not using the correct sample project. Package com.changemystyle.gentlewakeup is a non-working sample from me. The official sample project is here: radiobrowser4j-android-demo.tar.gz You should continue from this project and if any issues, integrate the code lines I posted.
|
Perhaps I am missing something obvious here, and that project doesn't build with minifyEnabled true as it's got an empty Proguard file. |
Adding the proguard entries you mention (with typos fixes), results in the same errors I am seeing.
EDIT; perhaps not typos, but Markdown doing weird things. Added what I am using to a code block. |
I am on holidays know for one week. Maybe sfuhrm can help you. I am just a user of the lib. If I come back and you have no solution I can take a look. |
Had another look at this today, I got something working, with a less aggressive ruleset, (i have only tested voteForStation, listStations, listStations, listStationsBy API calls), however it's working in a shrunk and obfuscated build. This is my reasonably optimised, working Proguard config, tested against radiobrowser4j 2.5.2, gradle 8.10, Android Studio Giraffe | 2022.3.1 using Java development and Java 1.8 language level.
I found this useful. Upload a regular build that's not been through ProGuard and play around in realtime with the ruleset. |
Hi guys, I'm reopening the issue since there are open questions regarding proguard. In the background the library is using Jersey Client which is using Jackson and JAXB, just to mention the bigger dependencies. It is failry ok to think that this amount of dependencies is not suited for an embedded target like Android. I have no ready list of classes that need to be defined as exceptions to proguard so everything is working. @fourofspades does your definition work for you? Does it make sense to already add it to the Android guide? Stephan |
…ymore. Tests are green. The endpoints the library is using are using JSON encoding, not XML. Removing JAXB dependency to make build smaller.
I have renamed this issue to "Android related questions" since it collects many good pointers for Android. |
Yes, done a fair amount of testing today and it's working well for me.
I guess the only open question is why the shorter configuration worked for
some but not for me...
…On Sun, 16 Jul 2023, 16:44 Stephan Fuhrmann, ***@***.***> wrote:
Hi guys,
I'm reopening the issue since there are open questions regarding proguard.
In the background the library is using Jersey Client which is using
Jackson and JAXB, just to mention the bigger dependencies. It is failry ok
to think that this amount of dependencies is not suited for an embedded
target like Android.
I have no ready list of classes that need to be defined as exceptions to
proguard so everything is working.
One strategy that might work is to turn on verbose class loading (don't
know whether Android has that) and then only include the classes from this
list. But it is probably a quite time consuming task.
@fourofspades <https://github.com/fourofspades> does your definition work
for you? Does it make sense to already add it to the Android guide
<https://github.com/sfuhrm/radiobrowser4j/blob/master/ANDROID.md>?
Stephan
—
Reply to this email directly, view it on GitHub
<#14 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOVZNJHF4ZGT47GVBYSCKETXQQD4PANCNFSM6AAAAAAR32ACHM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Updated to 2.5.2 and tested the Proguard, tested voting and searching API. it needed a rule tweak, which I changed in the comments above, and I also detailed the exact setup I am using. |
Had some crashes from users running my app in the wild, using the radiobrowser code on Android. It's not obfuscation related, as it happens in debug on the android emulator. Reverting to 2.5.0 fixes the issue. Interesting, it's only older devices that have this issue. Most of my bug reports come from Android 7.0 era. Stack trace: `
` |
Interesting! The Referring to this post, Android 7 had support for JDK 8. I am not sure whether this is correct when I read about your problem, as it would mean the Android is running JDK 7 or older. I see a dilemma here:
The target of this library is JDK 8 at the moment. Older really feels wrong. I'd suggest for antique Android support to Maven-exclude the Jackson stuff in your Application's pom/gradle file and depending on jackson libs 2.13.3. In the long term the approach using the Jersey-JAXRS-client needs to be replaced by something with less footprint to work smooth with Android. |
Guess this is the related bug report: |
Just for you info, guys. I've refactored the code a bit to go through 1 class. |
That's great news. Was this additional work something you were planning on doing, or are you expecting an android fork? |
@fourofspades I am planning an android fork, or a more android-friendly fork. I think reducing the dependency footprint is a good thing anyway. |
Thanks, that's great news, I'm still on version 2.50 as it was the last version I was able to persuade to work under Android. |
A little teaser: This is the (non test) dependencies of the new library. Left is the current version with Jersey and jackson, right is the new version with only GSon.
|
I have release a version 3.0.0 with quite some changes under the hood and some breaking changes in the API. Since the information in this thread only affects the previous versions, I'm closing the issue. |
Getting excellent results. It's reduced the size of my executable by almost 2Mb, which is great news, the only thing I needed to keep in my Proguard file was:
Tested the following API calls:
Along with endpoint discovery and the the new ConnectionParams.builder. Everything working perfectly. Many thanks. |
@fourofspades thanks for feedback! Let me know if you find bugs. |
Feels like the last step might be to embed Proguard configuration , so it works with Android out the box, with no additional changes. |
@fourofspades is there something that you could provide for that? May be in the form of a PR? |
Hi, did a bit of research online, and it appears this is one of the differences between a generic jar and an android specific aar library, the aar can include proguard configuration of the library itself, and it's not possible with jar. As it's only 2 lines to include, it's perhaps easier to update the readme, than mess around with an Android specific library. |
@fourofspades thanks for your research! Whatever way suits you, feel free to drop me either the passage for the readme or send a PR which updates it. |
@fourofspades PR merged. Thanks! |
I tried this library and after run example code, application crash and print this log.
I sought this problem in web, but can't find any solution.
java.lang.RuntimeException: java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.client.ClientBuilder cannot be found
at jakarta.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:77)
at de.sfuhrm.radiobrowser4j.RestClientFactory.newClient(RestClientFactory.java:27)
at de.sfuhrm.radiobrowser4j.RadioBrowser.(RadioBrowser.java:112)
at de.sfuhrm.radiobrowser4j.RadioBrowser.(RadioBrowser.java:79)
at de.sfuhrm.radiobrowser4j.RadioBrowser.(RadioBrowser.java:131)
Thanks and have a great day.
The text was updated successfully, but these errors were encountered: