blongho / worldCountryData

Android library for country flag, currency, and other country information
https://blongho.github.io/worldCountryData/doc/
MIT License
98 stars 35 forks source link

sing-up apk not working with your lib - When we set minifyEnabled true #18

Closed anilthummar closed 3 years ago

anilthummar commented 4 years ago

Thanks for you lib its grt work in debug mode app

buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } }

implementation 'com.google.android.material:material:1.1.0' implementation 'com.github.blongho:worldCountryData:v1.5'

        World.init(this);

not getting flag = World.getFlagOf("CountryName");

please help on that , I want to set minifyEnabled true when I create sign-up apk file

blongho commented 4 years ago

Hi, Sorry for the late reponse. Did you ever solve this? If no, can you paste the full error log here.?

anilthummar commented 4 years ago

@blongho thanks for updates.

No any error but When I have to create signup apk file that time country images from your com.github.blongho: world country data:v1.5 dependency

TravisTsai commented 3 years ago

I meet this problem, too. This is caused by proguard. It's ok in debug mode and set minifyEnabled to false. It seems like "getCountry" is null. I already config the proguard file as your project but still crash. Please help, thanks.

The crash stack is as following: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference at com.blongho.country_data.e.f(SourceFile:169) at com.blongho.country_data.e.i(SourceFile:129) at com.blongho.country_data.e.(SourceFile:53) at com.blongho.country_data.e.g(SourceFile:71) at com.blongho.country_data.d.init(SourceFile:50) at com.amazingtalker.MainApplication.onCreate(SourceFile:26) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6841) at android.app.ActivityThread.access$1400(ActivityThread.java:267)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)  at android.os.Handler.dispatchMessage(Handler.java:107)  at android.os.Looper.loop(Looper.java:237)  at android.app.ActivityThread.main(ActivityThread.java:7762)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047) 

The proguard file for using com.github.blongho:worldCountryData: -keep class com.blongho.country_data { ; } -keepparameternames -renamesourcefileattribute SourceFile

-keepattributes SourceFile,LineNumberTable -keepclasseswithmembers, allowoptimization enum { public static [] values(); public static valueOf(java.lang.String); } -keepclasseswithmembernames, includedescriptorclasses class { native ; } -keeppackagenames com.blongho.country_data -keepclassmembers class com.blongho.country_data. { public ; } -keep class com.blongho.country_data.R${ ; }

JosephLuns commented 3 years ago

Hello,

I have same issue too in release build. Anyone fixed this issue?

Thanks

blongho commented 3 years ago

It seems as if setting minified to true is the issue here.

I still have not found a working solution for that.

I made a sample app which is in the appstore.

Check my gradle here: CountryDataDemo

I have not tried this stack overflow answer

If anyone ever finds a work-around, then please update us.

However, if your app works online, you can use Rest Countries to fetch the data on-demand.

Regards Bernard

JosephLuns commented 3 years ago

Hello,

I have fixed it once I added your packages to the proguard exception.

BlongHo -> WorldCountryFlag

-keep class com.blongho.* {;} -keep interface com.blongho.**

Thanks

blongho commented 3 years ago

@JosephLuns thanks for your feedback.

congdanh1608 commented 3 years ago

Hello,

I have fixed it once I added your packages to the proguard exception.

BlongHo -> WorldCountryFlag

-keep class com.blongho.* {;} -keep interface com.blongho.**

Thanks

This issue only happens in release version because of proguard exception. We should add this into docs. Thank a lot.

blongho commented 3 years ago

Great 👏. I will update it soon