Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Android plugin crashes when built as AAR but not jar

Discussion in 'Android' started by hutch_jl, Mar 8, 2018.

  1. hutch_jl

    hutch_jl

    Joined:
    Jan 8, 2013
    Posts:
    40
    Hi,

    In order to comply with Google's messaging requirements for runtime permissions we've had to implement a plugin that overrides the main Unity activity to trigger a custom activity on startup to ask for the WRITE_EXTERNAL_STORAGE permission, before Unity starts up. If I just grab classes.jar and AndroidManifest.xml for the plugin after building in Android Studio this works great. If however I use the AAR output (from the same build), I get this crash:

    Caused by: java.lang.NoSuchMethodError: no non-static method "Lcom/unity3d/player/UnityPlayer;.initializeGoogleVr()Z"
    at com.unity3d.player.UnityPlayer.initJni(Native Method)
    at com.unity3d.player.UnityPlayer.<init>(Unknown Source)
    at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source)
    at com.prime31.UnityPlayerNativeActivity.onCreate(UnityPlayerNativeActivity.java:19)
    at com.hutchgames.bootobb.PlayerActivity.onCreate(PlayerActivity.java:20)
    at android.app.Activity.performCreate(Activity.java:6757)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2703)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2811)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6316)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

    Does anyone know what causes this/how to fix it? I need to add localisation so would prefer to use an AAR if I can.

    Thanks!
     
  2. wingshmRyu

    wingshmRyu

    Joined:
    Apr 10, 2018
    Posts:
    1
    Is initializeGoogleVr() a static method? If not, try ' Call("initializeGoogleVr") ' instead of ' CallStatic ("initializeGoogleVr") ' in your c # script.
     
  3. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,100
    Did you include the necessary VR SDKs in the Player Settings?
     
unityunity