Java Question java.lang.NoClassDefFoundError

MarcoRome

Expert
Licensed User
Hi all.
I'm trying to finish my library. But i have this error when i try this library into B4A

I have a java file that I compiled in jar ( look in attachment source + jar -- > TelephonyInfo.zip )

After i have this code:
B4X:
package simcard;
 
import TelephonyInfo.*;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import android.content.Context;
import android.telephony.*;
import android.view.*;
 
@Version(1.0f)
@ShortName("SimCard")
@Author("Devil-App")
@Permissions(values={"android.permission.READ_PHONE_STATE"})
 
 
 
public class SimCard{
  private TelephonyManager telephonyManager;
  private TelephonyInfo telephonyInfo;
/**
* Initialize - <link>Documentation:|http://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_ABSENT</link>.
*Example:<code>
*Dim sim As SimCard
*sim.Initialize()</code>
*/
  public void Initialize(final BA ba){
  telephonyManager = (TelephonyManager) ba.applicationContext.getSystemService(ba.applicationContext.TELEPHONY_SERVICE);
  /*telephonyInfo = TelephonyInfo.getInstance(this); */
  telephonyInfo = TelephonyInfo.getInstance(ba.context);
  }
 
 
/**
* Check if is DUAL SIM.
*Example:<code>
*Dim sim As SimCard
*Dim vero As boolean
*vero = sim.IsDualSIM</code>
*/
  public boolean IsDualSIM() {
     boolean sim2a = telephonyInfo.isDualSIM();
     return sim2a;
    }
 
 
 
/**
* Reads IMEI for GSM and the MEDI or ESN for CDMA phones and returns its content as a string.
*Example:<code>
*Dim sim As SimCard
*Dim text As String
*text = sim.Imei</code>
*/
  public String Imei() {
     String imei = telephonyManager.getDeviceId();
     return imei;
    }
...
}
I compile with Simple Library Compile 1.01 ( i put TelephonyInfo.jar in library folder ) and i have xml and jar without error. But when i try this library in B4A i have this error:

B4X:
LogCat connected to: emulator-5554
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
** Activity (main) Create, isFirst = true **
java.lang.NoClassDefFoundError: TelephonyInfo.TelephonyInfo
    at simcard.SimCard.Initialize(SimCard.java:63)
    at b4a.example.main._activity_create(main.java:319)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at b4a.example.main.afterFirstLayout(main.java:100)
    at b4a.example.main.access$100(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Create, isFirst = true **
Note the IMEI work without problem. I have problem about TelephonyInfo.TelephonyInfo.

What i wrong ???
Thank you all
Marco
 

Attachments

Last edited:

MarcoRome

Expert
Licensed User
Well...work but i have one question.
I must insert both jar ( my library and TelephonyInfo.jar ) in the library folder. Can i fill it all in a library ?
Thank you all
Marco
 
Top