Android Question error in SLC generated library, "missing metadata"

leitor79

Active Member
Licensed User
Longtime User
Hello,

I've made a custom library with notepad and SLC. It compiles right and I can use the functions I have there, but one of them gives me an exception within the java code:

java.lang.IllegalStateException: missing metadata: /com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US

I have checked and this file is located in a subfolder of the java library:

I don't know if these files should be in the data/data app folder once the app is installed, but they aren't. I don't see SLC processing them (i don't know if they should be). This are my slc layou, my slc log and my .java class header (should I add some tag?)





B4X:
package com.eitor.EitorLib;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import com.google.i18n.phonenumbers.*;
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
import android.util.Log;
import android.telephony.TelephonyManager;
import android.content.Context;

@ShortName("EitorLib")
@Version(24)
@Author("Me")



Thank you very much!
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I tried depending on the attached .jar and with ignore field blank and it worked without any problems.
 

Attachments

  • libphonenumber-7.0.jar
    296.6 KB · Views: 256
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hi somed3v3loper, thank you for your answer!

if with "tried depending on" you meant adding a @DependsOn clause in the java file, I get the following error when b4a compiles the app:

Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/google/i18n/phonenumbers/MetadataLoader;

If I remove the @DependsOn clause and all the source files of the libphonenumber and use the jar file in the lib folder (thing I've tried with libphonenumber-7.3.2, and tried again with your 7.0 jar), I get almost the same error:

java.lang.IllegalStateException: missing metadata: PhoneNumberMetadataProto_US

Note that this error does not have the previous error path (/com/google/i18n/phonenumbers/data), just the file name. Just in case, I've tried manually adding the file into the project, but I get the same error.

Thank you for your help!
 
Upvote 0

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I just used .jar no any other source code

B4X:
@DependsOn(values=("libphonenumber-7.0"))

And did not ignore any package
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hi Don, hi somed, thank you both for your answers.

I can't get it work with the ignore or not. With the ignored com.google I get the missing metadata error when I run the app, and without the ignore flag on slc I get the "already added" error when refreshing libraries.

I've been trying stuff, like manually adding the file into B4a, so it's copied in the data/data/app/files folder; also I've modified java code of several libraries in order to search for the file there and I still get the missing metadata error (java.lang.IllegalStateException: missing metadata: /data/data/eitor.contactsdemo/files/phonenumbermetadataproto_US, the file was lowercased when b4a copied it into the phone, I've renamed it to match the uppercased US)

ask some questions:

- Could the "already added" error be caused because I have the jar file in the customs library folder? (all the jars there are copied or registered somewhere when I compile the app?)

- The files located in phonenumbers/data folder are supposed to be copied to my phone? where? or they are being integrated into the custom library jar file?

Thank you very much for your help!
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Helly everyone,

After a zillion attempts, I've found a solution (I mean, it's working).

I was completely lost (I'm trying stuff since monday), trying everything I've read that could be remotely related to this (or not; I don't know java), and I get it working this way:

- ignores: org,com.android,com.example,com.hoho,com.google
- @DependsOn(values=("libphonenumber-7.3.2"))
- Only libphonenumber-7.3.2.jar in lib folder
- Added "additional" folder and put libphonenumber-7.3.2.pom file there, after unsuccefully putting a lost of stuff (all of the metadata files, por example), after misreading this post and take the .pom file for the .so file it refers to.

I hope it can help others in the future.

Thank you very much for your help!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…