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. Dismiss Notice

Unable to Instantiate Activity Crash for Some Users

Discussion in 'Android' started by kromenak, Dec 2, 2011.

  1. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    266
    Hey everyone,

    We've recently released our game on the Android market, and while things have mostly gone smoothly, we have noticed a chunk of crash errors reported by the Android Marketplace that look a bit suspicious:

    Code (csharp):
    1.  
    2. java.lang.RuntimeException: Unable to instantiate activity
    3. ComponentInfo{com.hiddenvariable.bagit/com.unity3d.player.UnityPlayerProxyActivity}:
    4. java.lang.ClassNotFoundException: com.unity3d.player.UnityPlayerProxyActivity in loader
    5. dalvik.system.PathClassLoader[/mnt/asec/com.hiddenvariable.bagit-1/pkg.apk]
    6. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2757)
    7. ...
    8. Caused by: java.lang.ClassNotFoundException: com.unity3d.player.UnityPlayerProxyActivity in loader
    9.  
    So, the game appears to be crashing at launch with an "Unable to Instantiate Activity" error? I've found some info regarding this on google, but nothing related to using Unity. How can I tell whether this is something up with Unity or something I can fix in my code?
     
    Deleted User likes this.
  2. Deleted User

    Deleted User

    Guest

    I've never seen this in a customer crash report, but I just ran into this error with a dev build. It looked like it was installed, but every time I ran it, got that error. When I rebooted the device, the installation was gone and a rebuild worked fine, so maybe somehow the installation was incomplete. But I've been getting a lot of weird run-and-test problems that were resolved with a device reboot (error about assetbundles built with wrong target, but just in one scene, and I don't use assetbundles...and multiple cannot-install-apk-bad-manifest errors). I wonder what's going on...
     
  3. maxime_adictiz

    maxime_adictiz

    Joined:
    Jun 17, 2014
    Posts:
    5
    Hi there.
    We just had the same problem and can't figure it out.
    Build&Run with Google Play eclipse project does not launch and crash.
    Everything is fine when Unity builds the package.
    Unity OSX 4.5.2f1
    Eclipse ADT Eclipse IDE for Android Developers 23.0.2.1259578
     
  4. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    @maxime_adictiz, you problem is completely unrelated to the first two posts in this thread. Check your android manifest and make sure package names and activities match.
     
  5. maxime_adictiz

    maxime_adictiz

    Joined:
    Jun 17, 2014
    Posts:
    5
    @bitter
    Thanx for your help.
    We've found yesterday that unity changes the package name of the UnityPlayerNativeActivity when exporting to a Google Play project.
    What is weird : The app APK installs and launch properly when built by Unity. Seems the unity build and google play export doesn't edit the manifest the same way.
    The package of the UnityPlayerNativeActivity is changed by google play project exportation process.
    As the native activity package is changed with the app one, the proxy activity (which keep the com.unity3d.player package) try to load the native activity in the same package, which was modified during the export process. Crash.

    As an exemple, if in my Plugins/Android folder I have my manifest with :
    manifest package named "com.company.app"
    activity package named "com.unity3d.player.UnityPlayerProxyActivity"
    activity package named "com.unity3d.player.UnityPlayerActivity"
    activity package named "com.unity3d.player.UnityPlayerNativeActivity"
    activity package named "com.unity3d.player.VideoPlayer"

    When I export as a google project, the manifest is edited by unity to :
    manifest package named "com.company.app"
    activity package named "com.unity3d.player.UnityPlayerProxyActivity"
    activity package named "com.unity3d.player.UnityPlayerActivity"
    activity package named "com.company.app.UnityPlayerNativeActivity"
    activity package named "com.unity3d.player.VideoPlayer"

    Which prevent the UnityPlayerProxyActivity or UnityPlayerActivity to find corresponding UnityPlayerNativeActivity.
    The only workaround we found is either to rename the package of UnityPlayerNativeActivity to the original com.unity3d.player after exportation, or to subclass all Unity activities as described in the plugins manual.

    Regards
     
    Andy M. likes this.
  6. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Ahhh.. that sort of makes sense. It's a bug. I'm guessing you have a custom AndroidManifest inside your Unity project. This is what is causing the error. The UnityPlayerProxyActivity and UnityPlayerActivity are no longer needed and thus are no longer renamed or exported properly (I'll make sure to fix this for a future release).

    If you sync your manifest with the one we ship with Unity it should work just fine. Basically move the launch Intent from the proxy activity to the NativeActivity and then (optionally) remove the proxy and regular java activity declarations from your custom manifest.
     
    Andy M. likes this.
  7. Nolex

    Nolex

    Joined:
    Dec 10, 2010
    Posts:
    115
    technicat thank you ! reboot and reistall helps me!
     
  8. biodam

    biodam

    Joined:
    Jul 10, 2013
    Posts:
    17
    Sorry to revive this old post. But I just got this same error.

    In my case, it was caused by the main AndroidManifest (the one at Plugin/Android/AndroidManifest.xml) added by jizc CloudOnce plugin for Google Play Game Services + Apple Game center.

    By deleting it Unity was able to generate the correct AndroidManifest in build and the plugin still works, so I think it may be needed for older versions of Unity.

    I'm using CloudOnce 2.6.2 and Unity 2018.3.0f2.

    Note: This error was not happening with Unity 2018.1.9f2, it emerged when I upgraded the project to 2018.3.0f2
     
    noracle likes this.
  9. ABI16

    ABI16

    Joined:
    Mar 19, 2019
    Posts:
    16
    I got the same error also with 2018.3.12f1. I did @biodam suggestion. I deleted also the AndroidManifest and it worked. The error is in the activity, from old Unity it accepts com.unity3d.player.UnityPlayerNativeActivity, with Unity 2018 it was generated as com.unity3d.player.UnityPlayerActivity.
    Then, I added other important parts from the old manifest to the new one (like the facebook activities and permissions) for the plugins and SDKs.