Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Combining Android Plugins with Different Package Names

Discussion in 'Android' started by numandina, Jul 20, 2013.

  1. numandina

    numandina

    Joined:
    Feb 22, 2013
    Posts:
    11
    Hello.

    I have two Android plugins I wish to use in my game, each with their own separate activity.

    I am having a difficult time correctly communicating between the two, with switching between activities and running calls inside.

    Here is my Manifest file:

    Code (csharp):
    1.  
    2.         ...
    3.        
    4.           <activity android:name="com.Company.Game.RRAndroidPluginActivity"
    5.                   android:label="My Game">
    6.            
    7.             <intent-filter>
    8.                 <action android:name="android.intent.action.MAIN" />
    9.                 <action android:name="android.intent.action.VIEW" />
    10.                 <category android:name="android.intent.category.DEFAULT" />
    11.                 <category android:name="android.intent.category.BROWSABLE" />
    12.                 <category android:name="android.intent.category.LAUNCHER" />
    13.             </intent-filter>
    14.         </activity>
    15.        
    16.         <activity
    17.             android:name="com.codiwans.iab.IAB"
    18.             android:screenOrientation="landscape"
    19.             android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    20.             android:label="My Game IAB"
    21.                 >
    22.            
    23.             <intent-filter>
    24.                 <action android:name="android.intent.action.MAIN" />
    25.                 <category android:name="android.intent.category.DEFAULT" />
    26.                 <category android:name="android.intent.category.BROWSABLE" />
    27.                 <action android:name="android.intent.action.VIEW" />
    28.             </intent-filter>
    29.            
    30.         </activity>
    31.  
    32.             ...
    33.  
    And here is the C# code I'm using:
    Code (csharp):
    1.  
    2. AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    3.  
    4. AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
    5.  
    6. AndroidJavaObject pm = jo.Call<AndroidJavaObject>("getPackageManager");
    7.  
    8. AndroidJavaObject intent = pm.Call<AndroidJavaObject>("getLaunchIntentForPackage", "com.codiwans.iab");
    9.  
    10. // AndroidJavaObject intent = pm.Call<AndroidJavaObject>("getLaunchIntentForPackage", "com.codiwans.iab.IAB");
    11.  
    12. jo.Call("startActivity", intent);
    But my game crashes on startup, with the error
    Code (csharp):
    1.  java.lang.NoClassDefFoundError
    .

    I can call static methods on the second activity, so I tried switching the activity through Java, but it too didn't work (return a NullReferenceError).

    Doing it in C# is perfect however, so if someone could help me out I would be very grateful. Spent the majority of last week digging into Eclipse and decompiling/compiling Java. I'm going crazy haha.

    Thanks for any hint.

    EDIT:

    I also get the following preceding errors:

    Code (csharp):
    1.  
    2. JNI: Unable to find method id for 'getClass'
    3.  
    4. JNI: Unable to find method id for 'getName'
    5.  
     
    Last edited: Jul 20, 2013
  2. numandina

    numandina

    Joined:
    Feb 22, 2013
    Posts:
    11
    Please, anyone?

    Both activities are MAIN. One of them is LAUNCHER.

    I can call methods successfully on both.

    I can't switch activity to the non-LAUNCHER one, however, getting the error specified (unable to find id for 'getClass').

    I feel so close, yet so far.

    Thanks.