I am using Unity to create an Android application.
I have two plugins. Each works fine on its own, but when I want both of them to be used, I can't switch between them.
I spent the last ten days, read all the similar questions, and tried everything from decompiling / editing / recompiling Java code to make it from Unity itself, but no luck.
Here is the last code I wrote and the errors I get.
My AndroidManifest.xml file:
... <activity android:name="com.Company.Game.RRAndroidPluginActivity" android:label="My Game"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.codiwans.iab.IAB" android:screenOrientation="landscape" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:label="My Game IAB" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter> </activity> ...
Here is the Unity code (in C #):
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); AndroidJavaObject pm = jo.Call<AndroidJavaObject>("getPackageManager"); AndroidJavaObject intent = pm.Call<AndroidJavaObject>("getLaunchIntentForPackage", "com.codiwans.iab.IAB"); jo.Call("startActivity", intent);
Here is the error I get:
JNI: Unable to find method id for 'getClass' Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54) JNI: Unable to find method id for 'getName' Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54) JNI: Unable to find method id for 'getName' Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54) Caused by: java.lang.NoClassDefFoundError: com/unity3d/player/UnityPlayer$12 at com.unity3d.player.UnityPlayer.setScreenSize(Unknown Source) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.onDrawFrame(Unknown Source) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216) Caused by: java.lang.NullPointerException at android.app.Instrumentation.execStartActivity(Instrumentation.java:1382) at android.app.Activity.startActivityForResult(Activity.java:3190) at android.app.Activity.startActivity(Activity.java:3297) ... 4 more
Both actions are MAIN. One of them is LAUNCHER.
I can successfully call methods for both.
I cannot switch the activity to non-LAUNCHER, however, indicating the indicated error (could not find the identifier for getClass).
I feel so close, but for now. Any help is appreciated. Go crazy here!
Thanks.