Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice
  2. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

Crash in Unity 2017: com.unity3d.player.UnityPlayer

Discussion in '2017.2 Beta' started by Selzier, Sep 1, 2017.

  1. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    644
    In Unity 5.6, the follow code works when when application is built to Android:
    Code (CSharp):
    1. using (AndroidJavaClass player = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
    However, in Unity 2017.1 and 2017.2, this line of code causes a crash. Here is the log from logcat:

    Code (CSharp):
    1.  
    2. FATAL EXCEPTION: main
    3. Process: com.mycompany.ProductName, PID: 19082
    4. java.lang.Error: FATAL EXCEPTION [main]
    5. Unity version     : 2017.2.0b9
    6. Device model      : samsung SM-G930V
    7. Device fingerprint: Verizon/heroqltevzw/heroqltevzw:7.0/NRD90M/G930VVRS4BQH1:user/release-keys
    8. Caused by: java.lang.NoSuchMethodError: [COLOR=#ff4d4d]No direct method <init>(Landroid/content/ContextWrapper;)V in class Lcom/unity3d/player/UnityPlayer; or its super classes (declaration of 'com.unity3d.player.UnityPlayer' appears in /data/app/com.mycompany.ProductName-1/base.apk[/COLOR])
    9.     at com.google.unity.GoogleUnityActivity.onCreate(GoogleUnityActivity.java:120)
    10.     at android.app.Activity.performCreate(Activity.java:6912)
    11.     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    12.     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
    13.     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
    14.     at android.app.ActivityThread.-wrap14(ActivityThread.java)
    15.     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
    16.     at android.os.Handler.dispatchMessage(Handler.java:102)
    17.     at android.os.Looper.loop(Looper.java:154)
    18.     at android.app.ActivityThread.main(ActivityThread.java:6688)
    19.     at java.lang.reflect.Method.invoke(Native Method)
    20.     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    21.     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
    22.  
    It seems to be a constructor call, but I am not sure as it works properly with Unity 5.6.

    In Unity 5.6
    Code (CSharp):
    1. public UnityPlayer(ContextWrapper contextwrapper)
    But in Unity 2017.1
    Code (CSharp):
    1. public UnityPlayer(Context context)
    What can we do to successfully build in Unity 2017?

    Reference:
    http://scriptlife.hacca.jp/contents/programming/2017/07/13/unity2017-1-error-android-unityplayer/
    Another report of this bug from Google Tango Github:
    https://github.com/googlesamples/tango-examples-unity/issues/102
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,862
    Hi Selzier,
    Could you please file a bug report with a minimal reproduction case for this issue and reply in here with the report #?
     
    GilCat, claytoncurmi and Selzier like this.
unityunity