Cannot start activity on Android through Unity
android, android-activity, android-intent, plugins, unity-game-engine
Solution
Your real problem is this: java.lang.NoClassDefFoundError: com/unity3d/player/UnityPlayer$12
For whatever reason java is not finding that class in your class path. Some research elsewhere showed that it may be related to a mismatch in the jar you're compiling against and the version you're developing against. It could also be that you don't have the jar in the correct place, or the version you're using doesn't provide that class.
I hope this at least helps point you in the right direction.
Problem
I'm using Unity to create an Android application. I have two plugins. Each works fine on its own, but when I want the both of them to be used I cannot switch activities between them. I have spent the past ten days reading all similar question and have tried everything from decompiling/editing/recompiling Java code to doing it from Unity itself, but no luck. Here is the final code I have written, 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 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. Any help is appreciated. Going crazy over here! Thanks.