Java Question I see my library but I can't use it?

leitor79

Active Member
Licensed User
Longtime User
Hi

I've generated a library using SLC, I've refreshed the libraries panel and I see mine, but I can't use or instantiate any of it.

The XML generated seems not to be right. Seems to miss some stuff:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<doclet-version-NOT-library-version>1.05</doclet-version-NOT-library-version>
</root>

I've uploaded the project here: https://www.dropbox.com/s/n21eqhen00f9c69/EitorPhoneValidator2.rar?dl=1

Thank you very much!
 

leitor79

Active Member
Licensed User
Longtime User
Hi Erel, thank you for your answer.

I've added @ShortName to the class I've "made" (copied and modified qualifies as "making"?), like this:

sshot-773.png


I'm not sure if this is the only "relevant class" of my project. The src folder of the project has many .java files; should I add @ShortName to all of them too? All .java files on any project subfolder should be considered as a relevant class?


Regards!
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Do you get such error
B4X:
java.lang.IllegalStateException: missing metadata: /com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US
 

leitor79

Active Member
Licensed User
Longtime User
Hello, everyone! Thanks for the answers!

Erel, what I've pasted is not the full code, it was just the declarations to show I've included (and where) the ShortName. The full code was uploaded with the project.

somed3v3loper, thank you very much for your help, it worked! (compiled and seen!). Just commented the DependsOn tag? And for sure you're a good developer but maybe you could do even better as a fortune teller? I'm getting the exact exception you've posted. Just by chance, haven't you also seen the solution? I recall reading something about a metadata folder, but I've searched here and the metadata info I find is not related to this metadata thing. In fact, I've noticed your post about the exception matching my exception when I came back here to ask.

Here is my updated java class:

B4X:
package com.eitor.eitorphonevalidator;
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;
//@DependsOn(values=("libphonenumbers-7.3"))
@ShortName("EitorPhoneValidator")
@Version(1)
@Author("EitorTeam")
public class EitorPhoneValidator {
    private PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
  
    public boolean Validate(String phoneNumber, String defaultCountry){
        boolean Resp = false;
        try {
              PhoneNumber number = phoneUtil.parseAndKeepRawInput(phoneNumber, defaultCountry);
              boolean isPossible = phoneUtil.isPossibleNumber(number);
              boolean isNumberValid = phoneUtil.isValidNumber(number);
              PhoneNumberType numberType = phoneUtil.getNumberType(number);
              boolean hasDefaultCountry = !defaultCountry.isEmpty() && defaultCountry != "ZZ";
              Resp = phoneUtil.isValidNumber(number);
        } catch (Exception e){
            Log.w("B4A", Log.getStackTraceString(e));
        }
        return Resp;
    }
   
    public String GetE164(String phoneNumber, String defaultCountry){
        String formattedNumber = "";
        try {
            PhoneNumber NumberProto = phoneUtil.parse(phoneNumber, defaultCountry);
            formattedNumber = phoneUtil.format(NumberProto, PhoneNumberFormat.E164);   
        } catch (Exception e){
           Log.w("B4A", Log.getStackTraceString(e));
        }
        return formattedNumber;
    }
}

Thank you very much!
 

leitor79

Active Member
Licensed User
Longtime User
After trying 1 billion things, some of them I too embarrassed to tell, I solved the issue just adding:

@DependsOn(values=("java-build-1.0-SNAPSHOT-jar-with-dependencies"))

java-build-1.0-SNAPSHOT-jar-with-dependencies is a jar file in my lib folder.

I think the issue was I also has the java source code of those jar files in my src folder (because I've already tried using dependson)

Thank you very much for your help!
 
Top