yasirkula / UnityNativeShare

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

Sharing file get "couldn't attach file" in gmail #112

Open dlungor opened 3 years ago

dlungor commented 3 years ago

Description of the bug

Gmail say's me "Couldn't attach file". Only on 11 android. I'm using it like this.

new NativeShare().AddFile(pathToAttachment).Share();

Reproduction steps

If possible, providing reproduction steps would be very helpful while pinpointing the issue. You can also post screenshots if you think they would be helpful.

Platform specs

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

Additional info

Android manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.unity3d.player" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:usesCleartextTraffic="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <activity android:name=".NativeShareCustomShareDialogActivity" android:theme="@style/Theme.NativeShareTransparent" />
    <!-- native toolkit -->
    <activity android:name="com.secondfury.nativetoolkit.MainActivity" android:configChanges="orientation|screenSize" />
    <activity android:name="com.secondfury.nativetoolkit.LocalNotificationResult" />
    <receiver android:name="com.secondfury.nativetoolkit.LocalNotification" />
    <!-- end native toolkit -->
    <activity android:name=".NativeShareCustomShareDialogActivity" android:theme="@style/Theme.NativeShareTransparent" />
    <provider
        android:name="com.yasirkula.unity.NativeShareContentProvider"
        android:authorities="SkyTrack_SkyTrack_Share"
        android:exported="false"
        android:grantUriPermissions="true"
        tools:replace="android:authorities"/>
  </application>

  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</manifest>
yasirkula commented 3 years ago

I'm assuming that pathToAttachment resides in either persistentDataPath or temporaryCachePath, as it should. Do you get the same error on other Android 11 devices/emulators? Do other free solutions like this also suffer the same issue?

dlungor commented 3 years ago

On another android 11 devices/emulators the same issue.

Path generated like this:

private static string GenerateNewFilePath(string extension)
    {
        return $"{Application.persistentDataPath}/{GenerateNewFileName(extension)}";
    }

Another solutions doesn't try yet

On android 10 all ok.

yasirkula commented 3 years ago

Please let me know when you try other free solutions.