MichaelRocks/libphonenumber-android

IllegalStateException: missing metadata

mohalaci opened this issue · 9 comments

I got this exception:

java.lang.IllegalStateException: missing metadata: /io/michaelrocks/libphonenumber/android/data/PhoneNumberMetadataProto_PR
at io.michaelrocks.libphonenumber.android.MetadataManager.getMetadataFromSingleFileName(MetadataManager.java:122)
at io.michaelrocks.libphonenumber.android.MetadataManager.getMetadataFromMultiFilePrefix(MetadataManager.java:108)
at io.michaelrocks.libphonenumber.android.MultiFileMetadataSourceImpl.getMetadataForRegion(MultiFileMetadataSourceImpl.java:72)
at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.getMetadataForRegion(PhoneNumberUtil.java:2232)
at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.getCountryCodeForValidRegion(PhoneNumberUtil.java:2393)
at io.michaelrocks.libphonenumber.android.PhoneNumberUtil.getCountryCodeForRegion(PhoneNumberUtil.java:2381)

Hi,

The file exists and it should work fine. Is it reproducible on the sample project? Do you have metadata files in the built APK?

@MichaelRocks the sample project is working fine. I decompiled my application and I didn't find the assets in the assets folder. I use DexGuard, maybe I have to add some new rules.

I think they're lost because of some tools you use, maybe because of DexGuard. Probably, the problem isn't related to the library itself.

Yes, maybe DexGuard removes these assets at build time. If I find the solution about how to use this library with DexGuard I will let you know.

Any solution to this @mohalaci? I ran into the same issue with Dexguard. Assets are removed.

@Anraza-Valtieri
I added this rule to dexguard:
-keepresourcefiles assets/**

@Anraza-Valtieri
I added this rule to dexguard:
-keepresourcefiles assets/**

Will give this a shot. Seems to be working! ^^

@mohalaci @Anraza-Valtieri Thank you. I've added a ProGuard config to the library with a similar rule. Hope it will work without any additional configuration on the app's side.

I had to remove DexGuard-specific options from the aar as it breaks D8 (#19). Instead I added a section for DexGuard users to README.