Comments (24)
I faced MissingResourceException even if -keep
option for i18n package.
java.util.MissingResourceException: Can't find resource for bundle 'org.ocpsoft.prettytime.i18n.Resources', key 'ePattern'
at java.util.ResourceBundle.missingResourceException(ResourceBundle.java:237)
at java.util.ResourceBundle.getObject(ResourceBundle.java:440)
at java.util.ResourceBundle.getString(ResourceBundle.java:456)
at org.ocpsoft.prettytime.i18n.e.<init>(Resources_ja.java:148)
at org.ocpsoft.prettytime.i18n.Resources_ja.a(Resources_ja.java:117)
at org.ocpsoft.prettytime.b.b.b(ResourcesTimeFormat.java:34)
at org.ocpsoft.prettytime.b.b.a(ResourcesTimeFormat.java:16)
at org.ocpsoft.prettytime.c.a(PrettyTime.java:143)
at org.ocpsoft.prettytime.c.<init>(PrettyTime.java:71)
I found Class#getSimpleName()
is used on obfuscated classes, in ja and fi resource bundles.
("ePattern" is built upon obfuscated TimeUnit class name "e" and "Pattern".)
In my case, -keepnames class ** implements org.ocpsoft.prettytime.TimeUnit
solved this Exception.
Resources.java and other bundle files didn't removed nor obfuscated even without -keep class org.ocpsoft.prettytime.i18n.**
(in my case, once again :) ).
from prettytime.
Just to make sure, did you solve this issue? It sounds like you did but I don't want to presume :)
from prettytime.
I still facing this issue even after add this lines on proguard file
-keep class org.ocpsoft.prettytime.** {*;} -dontwarn org.ocpsoft.prettytime.** -keep class com.ocpsoft.pretty.time.i18n.** {*;} -keep class org.ocpsoft.prettytime.i18n.Resources -keepnames class ** implements org.ocpsoft.prettytime.TimeUnit
from prettytime.
java.lang.ExceptionInInitializerError
at com.sickboots.sickvideos.b.run(Unknown Source)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.util.MissingResourceException: Can't find resource for bundle 'org.ocpsoft.prettytime.i18n.Resources_en_US', key ''
at java.util.ResourceBundle.missingResourceException(ResourceBundle.java:238)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:230)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:159)
at a.b.a.b.b.b(Unknown Source)
at a.b.a.b.b.a(Unknown Source)
at a.b.a.c.a(Unknown Source)
at a.b.a.c.(Unknown Source)
at com.sickboots.sickvideos.database.j.(Unknown Source)
... 2 more
from prettytime.
Turning off proguard fixes it, so I need to figure out how to config proguard to work with PrettyTime. Let me know if you figure it out and post instructions. Thanks.
OK, added this to my proguard-rules file
-keep class org.ocpsoft.prettytime.i18n.**
That seems to work, let me know if that's wrong. I don't know proguard well.
from prettytime.
Hey Steve,
Thanks for posting more details on this issue. We can add this to the PrettyTime FAQ if you think that this is the right solution. I'm not very familiar with Android (nor do I have a way to test it, so your thoughts are extremely helpful.)
Thank you for posting this workaround!
from prettytime.
Is proguard built in to android?
from prettytime.
Yeah, add this to the readme. It seems that many libraries on Android have the same issue. Proguard removed some necessary code from an included lib and it then crashes.
Proguard is recommended for production Android apps. You have to enable it on in your build.gradle file. I'm using Android Studio. My debug builds worked fine since they don't run Proguard.
In my app my build.gradle I tell it to use setting inside proguard-rules.txt
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
}
}
In proguard-rules.txt I have this:
fixes java.util.MissingResourceException: Can't find resource
for bundle 'org.ocpsoft.prettytime.i18n.Resources_en_US'
-keep class org.ocpsoft.prettytime.i18n.**
from prettytime.
Yes i solved, working fine in our app.
from prettytime.
- Only tested for ja locale.
from prettytime.
Great!
As far as the README update, what do folks need to add to make this work,
and where do they need to add it?
~Lincoln
On Mon, Jun 2, 2014 at 8:39 PM, Yuya Tanaka [email protected]
wrote:
- Only tested for ja locale.
—
Reply to this email directly or view it on GitHub
#68 (comment).
Lincoln Baxter, III
http://ocpsoft.org
"Simpler is better."
from prettytime.
i had the same issue as well.
Need to add the following:
-keep class org.ocpsoft.prettytime.i18n.**
to the proguard configuration of the app. Its usually named as "proguard.cfg"
Many thanks @sgehrman :)
from prettytime.
Thanks @anubhavsahoo, it was a lifesaver!
from prettytime.
@lincolnthree Thanks for the library. It would be really great if your could just add
-keep class org.ocpsoft.prettytime.i18n.** under Proguard for android so that developers don't have to go digging for obfuscation. :)
from prettytime.
Hey @izBasit - it appears that ProGuard isn't for libraries, just apps. So there's nothing I can do here, unless you can show me what to do or send a pull request I'm afraid I'm unable to continue. Thanks! Feel free to re-open if you find a solution I can implement.
from prettytime.
@lincolnthree Maybe I was unclear with my previous comment. Apologies for that.
In your ReadMe, can you please add the following message.
When using Proguard, please add
-keep class org.ocpsoft.prettytime.i18n.**
to your proguard script.
from prettytime.
Ah! I misunderstood. Thanks! I'll add that.
Lincoln Baxter, III
http://ocpsoft.org
"Simpler is better."
On Mon, Nov 30, 2015 at 11:37 AM, Basit Parkar [email protected]
wrote:
@lincolnthree https://github.com/lincolnthree Maybe I was unclear with
my previous comment. Apologies for that.
In your ReadMe, can you please add the following message.When using Proguard, please add
-keep class org.ocpsoft.prettytime.i18n.**
to your proguard script.—
Reply to this email directly or view it on GitHub
#68 (comment).
from prettytime.
We are using PrettyTime, but get errors while using Proguard on Android.
We use: -keep class org.ocpsoft.prettytime.i18n.**
Error we get:
java.util.MissingResourceException: Can't find resource for bundle 'org.ocpsoft.prettytime.i18n.Resources', key 'ePattern'
at java.util.ResourceBundle.missingResourceException(ResourceBundle.java:238)
at java.util.ResourceBundle.getObject(ResourceBundle.java:441)
at java.util.ResourceBundle.getString(ResourceBundle.java:457)
at org.ocpsoft.prettytime.i18n.Resources_ja$JaTimeFormat.<init>(SourceFile:155)
at org.ocpsoft.prettytime.i18n.Resources_ja.getFormatFor(SourceFile:122)
at org.ocpsoft.prettytime.impl.ResourcesTimeFormat.setLocale(SourceFile:34)
at org.ocpsoft.prettytime.impl.ResourcesTimeFormat.setLocale(SourceFile:16)
at org.ocpsoft.prettytime.PrettyTime.addUnit(SourceFile:714)
at org.ocpsoft.prettytime.c.<init>(SourceFile:78)
Issue seems to be same as @ypresto
I will investigate, but it seems to be useful to keep all classes for the whole library, instead of the i18n subpackage.
Something like: -keep class org.ocpsoft.prettytime.**
from prettytime.
I could reproduce the error, and with the following proguard config the error was gone. Please update the homepage.
-keep class org.ocpsoft.prettytime.** {*;}
-dontwarn org.ocpsoft.prettytime.**
This keeps all of the library, not only the i18n subpackage.
from prettytime.
The package name is changed.
I finally make it work with changing
-keep class org.ocpsoft.prettytime.i18n.**
to
-keep class com.ocpsoft.pretty.time.i18n.** {*;}
from prettytime.
how to fix this
Failed resolution of: Lorg/ocpsoft/prettytime/PrettyTime;
from prettytime.
I am also facing the same issue....
Failed resolution of: Lorg/ocpsoft/prettytime/PrettyTime;
Class not found Exception...
I tried everything as per told here...
But nothing comes out as useful ....
Just wanted to add... The library has been added as dependency in gradle... The object call points to the compiled classes only, but those classes not found at run time
from prettytime.
In my case, I fixed like this.
# for prettytime
-keep class com.ocpsoft.pretty.time.i18n.**
-keep class org.ocpsoft.prettytime.i18n.**
-keepnames class ** implements org.ocpsoft.prettytime.TimeUnit
from prettytime.
The problem does not arise for all languages, however, it occurs e.g. for the German language.
-keep class com.ocpsoft.pretty.time.i18n.**
-keepnames class ** implements org.ocpsoft.prettytime.TimeUnit
this solves the issue.
from prettytime.
Related Issues (20)
- format(List<Duration>) always throws a NullPointerException
- Add reference date to NLP PrettyTimeParser HOT 1
- constructor bug HOT 1
- pass reference to parse function HOT 3
- Weird class HOT 2
- Make use of java.time's ChronoUnit, Duration and Period. HOT 1
- Missing prettytime-parent 5.0.5 maven central HOT 4
- Can not download from pretty-time dependency, "could not find artifact" in IntelliJ Idea HOT 2
- New version HOT 2
- Some languages do not provide time units when formatting a duration HOT 1
- Jakarta JSF integration HOT 8
- Missing module-info.java HOT 9
- Japanese and Finnish locales and proguard HOT 3
- [Dutch] - Just now string is archaic HOT 1
- [prettytime-nlp] Android checkReleaseDuplicateClasses error in 5.0.7.Final HOT 6
- Ukrainian time is sometimes formatted with a negative sign HOT 7
- What's going on with the `v5.0.9` release?
- NOTICE for prettytime references prettyfaces
- Failed to load class "org.slf4j.impl.StaticLoggerBinder" HOT 1
- Incorrect localization for some languages HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettytime.