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:
sshot-803.png

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?)


sshot-804.png



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")

Starting step: Compiling Java code.
Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\eitor\eitorlib\EitorLib.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\AlternateFormatsCountryCodeSet.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\AsYouTypeFormatter.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\CountryCodeToRegionCodeMap.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\MetadataLoader.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\MetadataManager.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\MetadataSource.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\MultiFileMetadataSourceImpl.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\NumberParseException.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\Phonenumber.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\PhoneNumberMatch.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\PhoneNumberMatcher.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\PhoneNumberUtil.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\RegexCache.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\ShortNumberInfo.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\ShortNumbersRegionCodeSet.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\SingleFileMetadataSourceImpl.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\internal\MatcherApi.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\internal\RegexBasedMatcher.java...
Loading source file D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\src\com\google\i18n\phonenumbers\nano\Phonemetadata.java...
Constructing Javadoc information...
[-doclet, BADoclet]
[-docletpath, D:\USUARIOS\Leo\DESARROLLO\Android\b4a\SimpleLibraryCompiler]
[-doclet, BADoclet]
[-docletpath, D:\USUARIOS\Leo\DESARROLLO\Android\b4a\SimpleLibraryCompiler]
[-bootclasspath, D:\USUARIOS\Leo\DESARROLLO\Android\SDK\platforms\android-23\android.jar]
[-classpath, D:\USUARIOS\Leo\Programas\Basic4android\B4A.exe\../libraries\B4AShared.jar;D:\USUARIOS\Leo\Programas\Basic4android\B4A.exe\../libraries\Core.jar;D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\libs\libphonenumber-7.3.2.jar;D:\USUARIOS\Leo\DESARROLLO\Android\b4a\LibreriasPropias\EitorLib\libs\protobuf-java-2.6.1.jar;]
[-sourcepath, src]
[-b4atarget, D:\USUARIOS\Leo\DESARROLLO\Android\b4a\Librerias\EitorLib.xml]
[-b4aignore, org,com.android,com.example,com.hoho,com.google]
Ignoring: [org, com.android, com.example, com.hoho, com.google]
starting....
Working with class: com.eitor.EitorLib.EitorLib
finish: D:\USUARIOS\Leo\DESARROLLO\Android\b4a\Librerias\EitorLib.xml

Completed successfully.
*** Don't forget to refresh the libraries list in the IDE (right click and choose Refresh) ***


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: 253
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
Top