Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Crash when start a GoogleUnityActivity in android, can’t find lib

Discussion in 'Daydream' started by zurrix, Nov 22, 2016.

  1. zurrix

    zurrix

    Joined:
    Aug 6, 2014
    Posts:
    15
    I am trying to start a unity3d google VR project from a native android app, google library provide a class called GoogleUnityActivity to do this, it keep crash when the activity was invoked.


    //Start new unity activity

    Intent intent = new Intent(getActivity(), GoogleUnityActivity.class);

    getActivity().startActivity(intent);



    In android studio, the debug console log is below, I think it’s unity android activity can’t find those library it needed.

    ----------------------------------------------------------------------------------------------------------------------------------------------------
    I/OpenGLRenderer: Initialized EGL, version 1.4

    D/OpenGLRenderer: Swap behavior 1

    I/art: Do partial code cache collection, code=7KB, data=16KB

    I/art: After code cache collection, code=7KB, data=16KB

    I/art: Increasing code cache capacity to 128KB

    I/art: Do partial code cache collection, code=7KB, data=36KB

    I/art: After code cache collection, code=7KB, data=36KB

    I/art: Increasing code cache capacity to 256KB

    I/art: Compiler allocated 4MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)

    D/OpenGLRenderer: endAllActiveAnimators on 0xe72a5d00 (ListView) with handle 0xec483a60

    E/Unity: Unable to find libaudioplugingvrunity

    D/Unity: GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_vertex_half_float GL_OES_framebuffer_object GL_OES_rgb8_rgba8 GL_OES_compressed_ETC1_RGB8_texture GL_AMD_compressed_ATC_texture GL_KHR_texture_compression_astc_ldr GL_OES_texture_npot GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_OES_texture_3D GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_QCOM_alpha_test GL_OES_depth24 GL_OES_packed_depth_stencil GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_EXT_sRGB GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_EXT_texture_type_2_10_10_10_REV GL_EXT_texture_sRGB_decode GL_OES_element_index_uint GL_EXT_copy_image GL_EXT_geometry_shader GL_EXT_tessellation_shader GL_OES_texture_stencil8 GL_EXT_shader_io_blocks GL_OES_shader_image_atomic GL_OES_sample_variables GL_EXT_texture_border_clamp GL_EXT_multisampled_render_to_texture GL_OES_shader_multisample_interpolation GL_EXT_texture_cube_map_array GL_EXT_d

    D/Unity: raw_buffers_indexed GL_EXT_gpu_shader5 GL_EXT_robustness GL_EXT_texture_buffer GL_OES_texture_storage_multisample_2d_array GL_OES_sample_shading GL_OES_get_program_binary GL_EXT_debug_label GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_QCOM_tiled_rendering GL_ANDROID_extension_pack_es31a GL_EXT_primitive_bounding_box GL_OES_standard_derivatives GL_OES_vertex_array_object GL_EXT_disjoint_timer_query GL_KHR_debug GL_EXT_YUV_target GL_EXT_sRGB_write_control GL_EXT_texture_norm16 GL_EXT_discard_framebuffer GL_OES_surfaceless_context GL_OVR_multiview GL_OVR_multiview2 GL_EXT_texture_sRGB_R8 GL_KHR_no_error GL_EXT_debug_marker GL_OES_EGL_image_external_essl3 GL_OVR_multiview_multisampled_render_to_texture GL_EXT_buffer_storage GL_EXT_blit_framebuffer_params GL_EXT_protected_textures

    I/libOpenSLES: Emulating old channel mask behavior (ignoring positional mask 0x3, using default mask 0x3 based on channel count of 2)

    W/AudioTrack: notificationFrames=-10 clamped to the range -1 to -8

    D/AudioTrack: Client defaulted notificationFrames to 192 for frameCount 1536

    W/libc: pthread_create sched_setscheduler call failed: Operation not permitted

    W/libc: pthread_create sched_setscheduler call failed: Operation not permitted

    V/MediaRouter: Adding route: RouteInfo{ name=Phone, description=null, status=null, category=RouteCategory{ name=null types=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO groupable=false }, supportedTypes=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO , presentationDisplay=null }

    V/MediaRouter: Updating audio routes: AudioRoutesInfo{ type=SPEAKER }

    V/MediaRouter: Selecting route: RouteInfo{ name=Phone, description=null, status=null, category=RouteCategory{ name=null types=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO groupable=false }, supportedTypes=ROUTE_TYPE_LIVE_AUDIO ROUTE_TYPE_LIVE_VIDEO , presentationDisplay=null }

    D/NetworkSecurityConfig: No Network Security Config specified, using platform default

    W/System.err: java.lang.NoSuchMethodException: setAsyncReprojectionEnabled [boolean]

    W/System.err: at java.lang.Class.getMethod(Class.java:1981)

    W/System.err: at java.lang.Class.getMethod(Class.java:1637)

    W/System.err: at com.unity3d.player.UnityPlayer$12.run(Unknown Source)

    W/System.err: at android.os.Handler.handleCallback(Handler.java:751)

    W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)

    W/System.err: at android.os.Looper.loop(Looper.java:154)

    W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6119)

    W/System.err: at java.lang.reflect.Method.invoke(Native Method)

    W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)

    W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

    I/libOpenSLES: Emulating old channel mask behavior (ignoring positional mask 0x3, using default mask 0x3 based on channel count of 2)

    W/AudioTrack: notificationFrames=-10 clamped to the range -1 to -8

    D/AudioTrack: Client defaulted notificationFrames to 192 for frameCount 1536

    W/libc: pthread_create sched_setscheduler call failed: Operation not permitted

    I/libOpenSLES: Emulating old channel mask behavior (ignoring positional mask 0x3, using default mask 0x3 based on channel count of 2)

    W/AudioTrack: notificationFrames=-10 clamped to the range -1 to -8

    D/AudioTrack: Client defaulted notificationFrames to 192 for frameCount 1536

    W/libc: pthread_create sched_setscheduler call failed: Operation not permitted

    I/Unity: Initializing Daydream controller API.



    (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)

    I/Unity: Creating and initializing GVR API controller object.



    (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)

    W/System.err: java.lang.NoSuchMethodError: no non-static method "Lcom/google/vr/internal/controller/NativeCallbacks;.close()V"

    W/System.err: at com.unity3d.player.UnityPlayer.nativeRender(Native Method)

    W/System.err: at com.unity3d.player.UnityPlayer.a(Unknown Source)

    W/System.err: at com.unity3d.player.UnityPlayer$b$1.handleMessage(Unknown Source)

    W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)

    W/System.err: at android.os.Looper.loop(Looper.java:154)

    W/System.err: at com.unity3d.player.UnityPlayer$b.run(Unknown Source)

    A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 23905 (UnityMain)


    [ 11-21 15:10:37.386 376: 376 W/ ]

    debuggerd: handling request: pid=23711 uid=10127 gid=10127 tid=23905


    ------------------------------------------------------------------------------------------------------------------------------------------------

    In android studio project, I check all the libs needed in “./jniLibs/platformname/*.so”, it’s all here and can be compiled well in android java code, for example:the “libaudioplugingvrunity.so”.


    But the unity activity in android can’t find those library when embedded to android project.

    I also unzipped apks, there are same “*.so” in “apk/lib/platformname/”, why unityactivity can’t find the libs when embedded into android native app? How unity or mono locate the libs when they do [dllimport]?
     
  2. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    GoogleUnityActivity is nolonger the correct activity to create with the technical preview. I think you should be creating just the UnityPlayerActivity.
     
  3. zurrix

    zurrix

    Joined:
    Aug 6, 2014
    Posts:
    15
    I also tried UnityPlayerActivity, but it seems can't enter VR mode, also without gvrview or gvrcontroller support, it just a normal unity3d view . Anything I should do after start UnityPlayerActivity, similar to what had been done in GoolgeUnityAcitivy?
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    You need to make sure you have the gvr and protobuf libraries. I suggest you use the Technical Preview to create a new Daydream project, export that to an Android Project and grab the libs from there.
     
  5. zurrix

    zurrix

    Joined:
    Aug 6, 2014
    Posts:
    15
    I tried the example project in grv sdk, it also get the same problem.
     
  6. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    did you enable Virtual Reality support in Android player settings, and add cardboard or daydream to the list of VR SDKs? That should give you the needed libraries, and when UnityPlayerActivity is started it will add the gvrview etc to the view hierarchy.
     
  7. zurrix

    zurrix

    Joined:
    Aug 6, 2014
    Posts:
    15
    Yes, I enable VR support and add daydream to it, it runs well when export to Pixel Phone. Only when export to android project and start from android as an activity it failed.
     
  8. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Hmm... something seems to have changed in Android Studio. I just exported a new project and opened it in AS and, after a lot of digging and poking I see that in the Module Settings for the main application there is a problem. Apparently the classes.jar file in the gvr project is not set as a dependency and you need to manually add it. I selected the 'Fix' option and had it fix the gvr library to have that dependency but it might also work on the application.

    Take a look and see if you have the same issue.
     
  9. zurrix

    zurrix

    Joined:
    Aug 6, 2014
    Posts:
    15
    When include the gvr classes.jar to the AS project and set it as a dependency, it shows more than one library with "com.google.vr.cardboard" is included.

    I thinks the problem is, you include the unity exported project to AS, and then there's no GoogleUnityActivity included in the library.

    I include the project in GVR unity plugin package library, with gvr_android_common.aar and unitygvractivity.aar, which include the GoogleUnityActivity.

    Then I remove the lib "gvr_android_common.aar" and include the unitygvractivity.aar with gvr "classes.jar", it works!

    but it still shows that it can't find the libaudiopluginvrunity.so
    E/Unity: Unable to find libaudioplugingvrunity

    I don't know why but I think the google vr unity plugin should be updated. ;)
     
    Last edited: Nov 22, 2016
  10. gyosida

    gyosida

    Joined:
    Jun 9, 2017
    Posts:
    1
    I know has been a while but did you finally get the activity to be launched?