itaied
itaied

Reputation: 7107

JAVA NoClassDefFoundError on external jar library

I'm writing an Android app in JAVA using this library for formatting phone numbers. I am receiving the following exception:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/i18n/phonenumbers/PhoneNumberUtil;

Here:

public class InvocationTargetException extends ReflectiveOperationException  {
...
public InvocationTargetException(Throwable exception) {
    super(null, exception);
    target = exception;
}
...
}

When executing the command:

PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();

I have imported the com.google.i18n.phonenumbers lib, but I cant figure out what is the L in the exception description.

Upvotes: 0

Views: 2144

Answers (2)

Khanad
Khanad

Reputation: 233

Did you add the jar file to your class path? Are you using Android Studio? In that case you can add the entry to the app/build.gradle file.

Upvotes: 0

K139
K139

Reputation: 3669

L is added for internal JVM objectype representation, but it is actually looking for com/google/i18n/phonenumbers/PhoneNumberUtil class.

It seems the library is missing in your Runtime classpath.

Field Descriptions Documentation.

Upvotes: 2

Related Questions