Java Question java.lang.NoClassDefFoundError

Discussion in 'Libraries developers questions' started by MarcoRome, Feb 25, 2015.

  1. MarcoRome

    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:
    Code:
    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:

    Code:
    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
     

    Attached Files:

    Last edited: Feb 25, 2015
  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Add
    Code:
    @DependsOn({"TelephonyInfo"})
    or something like that.
     
    DonManfred and MarcoRome like this.
  3. MarcoRome

    MarcoRome Expert Licensed User

    Thank you Thedesolatesoul ;) now work
     
  4. MarcoRome

    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
     
  5. DonManfred

    DonManfred Expert Licensed User

    that´s usually the best way (letting the 3rd party jar as it is)
     
    MarcoRome likes this.
  6. MarcoRome

    MarcoRome Expert Licensed User

    ok... thanks DonManfred
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice