yasirkula / UnityNativeShare

A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS
MIT License
891 stars 131 forks source link

Unity 2020 NativeShare #97

Closed gbdb71 closed 3 years ago

gbdb71 commented 3 years ago

Description of the bug

Plugin doesn't work when compiling .aab package with Unity 2020. AndroidManifest.xml includes plugin reference correctly, apparently.

Reproduction steps Compile .aab bundle . Subsequent .apk and .aab plugin will not work.

Platform specs Linux Ubuntu + Unity 2020.1.9f1

Please provide the following info if this is a Unity 3D repository.

Additional info

AndroidJavaException: java.lang.ClassNotFoundException: com.yasirkula.unity.NativeShare 12-21 10:31:00.454 27564 27616 E Unity : java.lang.ClassNotFoundException: com.yasirkula.unity.NativeShare 12-21 10:31:00.454 27564 27616 E Unity : at java.lang.Class.classForName(Native Method) 12-21 10:31:00.454 27564 27616 E Unity : at java.lang.Class.forName(Class.java:453) 12-21 10:31:00.454 27564 27616 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 12-21 10:31:00.454 27564 27616 E Unity : at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) 12-21 10:31:00.454 27564 27616 E Unity : at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) 12-21 10:31:00.454 27564 27616 E Unity : at android.os.Handler.dispatchMessage(Handler.java:102) 12-21 10:31:00.454 27564 27616 E Unity : at android.os.Looper.loop(Looper.java:176) 12-21 10:31:00.454 27564 27616 E Unity : at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 12-21 10:31:00.454 27564 27616 E Unity : Caused by: java.lang.ClassNotFoundException: Didn't find class "com.yasirkula.unity.NativeShare" on path: DexPathList[[zip file "/data/app/com.Gabgames.Knhop-mwuk_w9DXJSaPpmaALnPrQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.Gabgames.Knhop-mwuk_w9DXJSaPpmaALnPrQ==/lib/arm64, /data/app/com.Gabgames.Knhop-mwuk_w9DXJSaPpmaALnPrQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]] 12-21 10:31:00.454 27564 27616 E Unity : at dalvik.syst

yasirkula commented 3 years ago

Did you check out the relevant FAQ entry?

gbdb71 commented 3 years ago

https://assetstore.unity.com/packages/tools/integration/native-share-for-android-ios-112731 Not using Proguard, unchecked option in Player Settings.

  • Can't share, it says "java.lang.ClassNotFoundException: com.yasirkula.unity.NativeShare" in Logcat If your project uses ProGuard, try adding the following line to ProGuard filters: -keep class com.yasirkula.unity. { ; }
yasirkula commented 3 years ago

Is any other Minification option enabled, like Gradle?

gbdb71 commented 3 years ago

No, all disabled. It must be something related to .aab. If I manage to make a new project and compile it as .apk sharing works. But as soon as I compile it as .aab subsequent builds, even as .apk, won't allow sharing.

yasirkula commented 3 years ago

There is definitely some sort of minification going on there because Minification=Stripping com.yasirkula.unity.NativeShare class=java.lang.ClassNotFoundException. What I don't know is, what kind of minification Android App Bundle internally runs. I couldn't find any information about minification related to .aab's, so I can't resolve this issue at the moment.

gbdb71 commented 3 years ago

This worked. Needed to set Proguard ON in build settings/player settings for it to work properly. Whitout Proguard share didn't work, maybe default .aab security settings of same sort?

yasirkula commented 3 years ago

Then I think AAB enables ProGuard by default. Happy to hear that the issue is resolved.