Search Unity

Android JAR usage

Discussion in 'Android' started by bpritchard, Jan 9, 2016.

  1. bpritchard

    bpritchard

    Joined:
    Jan 29, 2009
    Posts:
    444
    Afternoon all,

    I am trying to implement a plugin using an existing JAR file from a customer and i'm just running into a wall every time i make a change. Basically the plugin is loading and the apk from unity is building but once i try and run anything from the provided SDK it can't find ANY Of the referenced classes within.

    thinking that they might just be referenced in the jar and not included i copied over the additional jar files but that broke basically saying there were duplicates.

    From there i've tried adding in the individual activities in the manifest and thats not making a difference either.

    Below is the function i setup in unity.. which is does work to an extent by firing off the INIT function within the SDK jar, but then fails when INIT is looking for its related functions in the jar.

    Any thoughts on what I could be doing wrong? Seems as though if the jar itself is working and it is getting load into the app properly then it should understand all of the references within the actual jar itself.

    Code (CSharp):
    1.         if (JPRObject == null) {
    2.             using (AndroidJavaClass activityClass = new AndroidJavaClass ("com.unity3d.player.UnityPlayer")) {
    3.                 Debug.Log ("**********  Setting up JPRObject **********");
    4.                 activityContext = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
    5.                 Debug.Log ("**********  ActivityContet is now set to the currentActivity **********");
    6.             }
    7.         }
    8.         using (AndroidJavaClass pluginClass = new AndroidJavaClass ("com.jr.sdk.JR")) {
    9.             if (pluginClass != null) {
    10.                 JPRObject = pluginClass.CallStatic<AndroidJavaObject> ("instance");
    11.                 activityContext.Call ("runOnUiThread", new AndroidJavaRunnable (() => {
    12.                     Debug.Log ("**********  Performin INIT **********");
    13.                     JPRObject.Call ("UnityJPInit", APIKey, activityContext);
    14.                     Debug.Log ("**********  INIT Finished **********");
    15.                 }));
    16.             }
    17.         }

    and here's an example of the errors i get..

    Code (CSharp):
    1. 01-10 08:10:55.896: I/dalvikvm(28301): Could not find method net.danlew.android.joda.JodaTimeAndroid.init, referenced from method com.jr.sdk.JR.Init
    2. 01-10 08:10:55.896: W/dalvikvm(28301): VFY: unable to resolve static method 6357: Lnet/danlew/android/joda/JodaTimeAndroid;.init (Landroid/content/Context;)V
    3. 01-10 08:10:55.896: D/dalvikvm(28301): VFY: replacing opcode 0x71 at 0x000c
    4. 01-10 08:10:55.896: W/dalvikvm(28301): Unable to resolve superclass of Lcom/jr/sdk/views/activities/LoginActivity; (155)
    5. 01-10 08:10:55.896: W/dalvikvm(28301): Link of class 'Lcom/jr/sdk/views/activities/LoginActivity;' failed
    6. 01-10 08:10:55.896: E/dalvikvm(28301): Could not find class 'com.jr.sdk.views.activities.LoginActivity', referenced from method com.jr.sdk.JR.showDashboard
    7. 01-10 08:10:55.896: W/dalvikvm(28301): VFY: unable to resolve const-class 641 (Lcom/jr/sdk/views/activities/LoginActivity;) in Lcom/jr/sdk/JR;
    8.  
    Thanks so much in advance.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    The SDK that you received as a .jar probably references other libraries with types that it needs for properly working. In case you only include the "SDK" .jar in your project it doesn't work.