Giter Club home page Giter Club logo

Comments (24)

ypresto avatar ypresto commented on September 24, 2024 4

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.

lincolnthree avatar lincolnthree commented on September 24, 2024 1

Just to make sure, did you solve this issue? It sounds like you did but I don't want to presume :)

from prettytime.

MML-Pro avatar MML-Pro commented on September 24, 2024 1

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.

sgehrman avatar sgehrman commented on September 24, 2024

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.

sgehrman avatar sgehrman commented on September 24, 2024

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.

lincolnthree avatar lincolnthree commented on September 24, 2024

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.

lincolnthree avatar lincolnthree commented on September 24, 2024

Is proguard built in to android?

from prettytime.

sgehrman avatar sgehrman commented on September 24, 2024

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.

ypresto avatar ypresto commented on September 24, 2024

Yes i solved, working fine in our app.

from prettytime.

ypresto avatar ypresto commented on September 24, 2024
  • Only tested for ja locale.

from prettytime.

lincolnthree avatar lincolnthree commented on September 24, 2024

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.

anubhavsahoo avatar anubhavsahoo commented on September 24, 2024

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.

levelibeeka avatar levelibeeka commented on September 24, 2024

Thanks @anubhavsahoo, it was a lifesaver!

from prettytime.

izBasit avatar izBasit commented on September 24, 2024

@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.

lincolnthree avatar lincolnthree commented on September 24, 2024

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.

izBasit avatar izBasit commented on September 24, 2024

@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.

lincolnthree avatar lincolnthree commented on September 24, 2024

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.

peterdk avatar peterdk commented on September 24, 2024

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.

peterdk avatar peterdk commented on September 24, 2024

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.

shopmini avatar shopmini commented on September 24, 2024

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.

asywalulfikri avatar asywalulfikri commented on September 24, 2024

how to fix this

Failed resolution of: Lorg/ocpsoft/prettytime/PrettyTime;

from prettytime.

MahindraBhuman avatar MahindraBhuman commented on September 24, 2024

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.

masaibar avatar masaibar commented on September 24, 2024

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.

Piorko avatar Piorko commented on September 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.