videokit-ai / natshare

Cross-platform social sharing for Unity Engine.
https://github.com/natmlx/videokit
Apache License 2.0
134 stars 28 forks source link

Crashed on Android 11 with Proguard #115

Closed ShortArrow closed 3 years ago

ShortArrow commented 3 years ago

Environment

Problem

NetShare is good job on iOS. But crash on Android!

Code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NatSuite.Sharing;

public class Shares : MonoBehaviour
{
    public void OnClickShareButton()
    {
        this.Share();
    }
    public void Share()
    {
        var payload = new SharePayload();
        payload.AddText("Simple and amusing");
        payload.Commit();
    }
}

Error Message

I show my adb logcat data.

02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655] Aborting thread:
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655] "UnityMain" prio=5 tid=16 Native
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   | group="" sCount=0 dsCount=0 flags=0 obj=0x12e805e8 self=0xdc590a10
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   | sysTid=24579 nice=0 cgrp=default sched=0/0 handle=0xba0bc1c0
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   | state=R schedstat=( 22623285990 3184703995 31909 ) utm=1836 stm=426 core=6 HZ=100
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   | stack=0xb9fb9000-0xb9fbb000 stackSize=1040KB
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   | held mutexes= "abort lock"
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #00 pc 00373d6d  /apex/com.android.art/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+76)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #01 pc 004438f3  /apex/com.android.art/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap*, bool) const+386)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #02 pc 0043f1eb  /apex/com.android.art/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap*, bool) const+34)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #03 pc 0041153f  /apex/com.android.art/lib/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*) const+30)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #04 pc 004020b9  /apex/com.android.art/lib/libart.so (art::Runtime::Abort(char const*)+1876)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #05 pc 0000d993  /system/lib/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+46)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #06 pc 0000d2b1  /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+224)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #07 pc 0029594b  /apex/com.android.art/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1922)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #08 pc 002a8f4f  /apex/com.android.art/lib/libart.so (art::JNI<false>::GetMethodID(_JNIEnv*, _jclass*, char const*, char const*)+1278)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #09 pc 00000a9b  /data/app/~~TOrJENzORnRivV10pEF8Gw==/com.me.appname-e2aEsj9a_lPpQy1JXdXItQ==/lib/arm/libNatShare.so (???)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #10 pc 00000999  /data/app/~~TOrJENzORnRivV10pEF8Gw==/com.me.appname-e2aEsj9a_lPpQy1JXdXItQ==/lib/arm/libNatShare.so (NSCreateSharePayload+28)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   native: #11 pc 0000b04a  <anonymous:bb3b0000> (???)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at com.unity3d.player.UnityPlayer.nativeRender(Native method)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at com.unity3d.player.UnityPlayer.access$300(:-1)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at com.unity3d.player.UnityPlayer$e$1.handleMessage(:-1)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at android.os.Handler.dispatchMessage(Handler.java:102)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at android.os.Looper.loop(Looper.java:223)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at com.unity3d.player.UnityPlayer$e.run(:-1)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655] Pending exception java.lang.ClassNotFoundException: api.natsuite.natshare.NativeCallback
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at boolean com.unity3d.player.UnityPlayer.nativeRender() (:-2)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) (:-1)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) (:-1)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at void android.os.Looper.loop() (Looper.java:223)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]   at void com.unity3d.player.UnityPlayer$e.run() (:-1)
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:655]
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:663] JNI DETECTED ERROR IN APPLICATION: java_class == null
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:663]     in call to GetMethodID
02-16 16:51:17.181 24557 24579 F me.appname: runtime.cc:663]     from boolean com.unity3d.player.UnityPlayer.nativeRender()
02-16 16:51:17.193 24557 24579 E CRASH   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-16 16:51:17.193 24557 24579 E CRASH   : Version '2019.4.19f1 (ca5b14067cec)', Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a'
02-16 16:51:17.193 24557 24579 E CRASH   : Build fingerprint: 'google/flame/flame:11/RQ1A.210205.004/7038034:user/release-keys'
02-16 16:51:17.193 24557 24579 E CRASH   : Revision: 'MP1.0'
02-16 16:51:17.193 24557 24579 E CRASH   : ABI: 'arm'
02-16 16:51:17.193 24557 24579 E CRASH   : Timestamp: 2021-02-16 16:51:17+0900
02-16 16:51:17.193 24557 24579 E CRASH   : pid: 24557, tid: 24579, name: UnityMain  >>> com.me.appname <<<
02-16 16:51:17.193 24557 24579 E CRASH   : uid: 10453
02-16 16:51:17.193 24557 24579 E CRASH   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
02-16 16:51:17.193 24557 24579 E CRASH   :     r0  00000000  r1  00006003  r2  00000006  r3  ba0ba990
02-16 16:51:17.193 24557 24579 E CRASH   :     r4  ba0ba9a4  r5  ba0ba988  r6  00005fed  r7  0000016b
02-16 16:51:17.193 24557 24579 E CRASH   :     r8  ba0ba990  r9  ba0ba9a0  r10 ba0ba9c0  r11 ba0ba9b0
02-16 16:51:17.193 24557 24579 E CRASH   :     ip  00006003  sp  ba0ba960  lr  e8a848c1  pc  e8a848d4
02-16 16:51:17.193 24557 24579 E CRASH   : backtrace:
02-16 16:51:17.193 24557 24579 E CRASH   :       #00 pc 000378d4  /apex/com.android.runtime/lib/bionic/libc.so (prop_area::map_prop_area_rw(char const*, char const*, bool*)+228) (BuildId: df8ca6ccfbad58cfa23ed53ef0fb62e4)
02-16 16:51:17.193 24557 24579 E CRASH   :       #01 pc 00003fbd  /system/lib/liblog.so (create_android_logger+34) (BuildId: d47690184a8491c6d6cee2641017deb3)
02-16 16:51:17.199 24557 24579 E CRASH   : managed backtrace:
02-16 16:51:17.199 24557 24579 E CRASH   :       #00 (wrapper managed-to-native) NatSuite.Sharing.Internal.Bridge:CreateSharePayload (NatSuite.Sharing.Internal.Bridge/CompletionHandler,intptr)
02-16 16:51:17.199 24557 24579 E CRASH   :       #01 NatSuite.Sharing.SharePayload/<>c:<.ctor>b__0_0 (NatSuite.Sharing.Internal.Bridge/CompletionHandler,intptr) <0x1f>
02-16 16:51:17.199 24557 24579 E CRASH   :       #02 NatSuite.Sharing.Internal.NativePayload:.ctor (System.Func`3<NatSuite.Sharing.Internal.Bridge/CompletionHandler, intptr, intptr>) <0x97>
02-16 16:51:17.199 24557 24579 E CRASH   :       #03 NatSuite.Sharing.SharePayload:.ctor () <0x9f>
02-16 16:51:17.199 24557 24579 E CRASH   :       #04 Shares:Share () <0x1f>
02-16 16:51:17.199 24557 24579 E CRASH   :       #05 Shares:OnClickShareButton () <0x13>
02-16 16:51:17.199 24557 24579 E CRASH   :       #06 UnityEngine.Events.InvokableCall:Invoke () <0x3b>
02-16 16:51:17.199 24557 24579 E CRASH   :       #07 UnityEngine.Events.UnityEvent:Invoke () <0xc7>
02-16 16:51:17.199 24557 24579 E CRASH   :       #08 UnityEngine.UI.Button:Press () <0x5b>
02-16 16:51:17.199 24557 24579 E CRASH   :       #09 UnityEngine.UI.Button:OnPointerClick (UnityEngine.EventSystems.PointerEventData) <0x27>
02-16 16:51:17.199 24557 24579 E CRASH   :       #10 UnityEngine.EventSystems.ExecuteEvents:Execute (UnityEngine.EventSystems.IPointerClickHandler,UnityEngine.EventSystems.BaseEventData) <0x3f>
02-16 16:51:17.199 24557 24579 E CRASH   :       #11 UnityEngine.EventSystems.ExecuteEvents:Execute<T_REF> (UnityEngine.GameObject,UnityEngine.EventSystems.BaseEventData,UnityEngine.EventSystems.ExecuteEvents/EventFunction`1<T_REF>) <0x25b>
02-16 16:51:17.199 24557 24579 E CRASH   :       #12 UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress (UnityEngine.EventSystems.PointerEventData,bool,bool) <0x383>
02-16 16:51:17.199 24557 24579 E CRASH   :       #13 UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents () <0x133>
02-16 16:51:17.199 24557 24579 E CRASH   :       #14 UnityEngine.EventSystems.StandaloneInputModule:Process () <0x4b>
02-16 16:51:17.199 24557 24579 E CRASH   :       #15 UnityEngine.EventSystems.EventSystem:Update () <0x1df>
02-16 16:51:17.199 24557 24579 E CRASH   :       #16 (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
02-16 16:51:17.929 24557 24579 E CRASH   : Tombstone written to: /storage/emulated/0/Android/data/com.me.appname/files/tombstone_00
02-16 16:51:17.929 24557 24579 F me.appname: thread.cc:2361] No pending exception expected: java.lang.ClassNotFoundException: api.natsuite.natshare.NativeCallback
02-16 16:51:17.929 24557 24579 F me.appname: thread.cc:2361]   at boolean com.unity3d.player.UnityPlayer.nativeRender() (:-2)
02-16 16:51:17.929 24557 24579 F me.appname: thread.cc:2361]   at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) (:-1)
02-16 16:51:17.929 24557 24579 F me.appname: thread.cc:2361]   at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) (:-1)
02-16 16:51:17.929 24557 24579 F me.appname: thread.cc:2361]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
02-16 16:51:17.929 24557 24579 F me.appname: thread.cc:2361]   at void android.os.Looper.loop() (Looper.java:223)
02-16 16:51:17.929 24557 24579 F me.appname: thread.cc:2361]   at void com.unity3d.player.UnityPlayer$e.run() (:-1)
02-16 16:51:17.929 24557 24579 F me.appname: thread.cc:2361]
ShortArrow commented 3 years ago

I think the following is important in ⬆️.

Pending exception java.lang.ClassNotFoundException: api.natsuite.natshare.NativeCallback

So I tried turn off Proguard. After that myapp show expected behavior on Android 11!

So searching for way how to use both Proguard and NatShare.

Because I need Proguard!

First, I tried to put the "Custum Proguard Setting Text File". then I included this code.

-keep class api.natsuite.natshare.NativeCallback{ *; }

But this is nothing effects.

image

Am I making a mistake in the syntax? Or is the specified class name different?

ShortArrow commented 3 years ago

how to use both Proguard and NatShare.

Assets\Plugins\Android\proguard-user.txt

-keep class api.natsuite.**{
    *;
}

This is own answer.

olokobayusuf commented 3 years ago

This is a good note. I will add the note about Proguard to the online docs. But your rule is correct, you need to keep anything with api.natsuite.*.