vinzscam/react-native-file-viewer

react-native-file-viewer not working on Android 11

faizanbuggy opened this issue ยท 23 comments

I am using react-native-file-viewer on android to open pdf files. It is working fine on Android 10 but gives the error "No app associated with this mime type" on Android 11 and opens google play store to download an app with a mime: application/pdf. If I download any app it still redirects me to the app store the next time.
Please help

Same issue! ๐Ÿ‘

@faizanbuggy Add following query into your manifest. It's working for me with 30th API version.

...
<queries>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:mimeType="*/*" />
    </intent>
...
</queries>```

Hello. I also have an issue:
The documents uploading fine via application but it's not opening there.
When I am opening file via Android program it said that "File type is not supported or damaged" but this is a standart JPG or doc file. Will it be fixed in the nearest future?

@slava-the-skills Do we need an PR for this?

@slava-the-skills Thanks a lot!. It worked for Pdf, But not working docx file format.

@faizanbuggy Add following query into your manifest. It's working for me with 30th API version.

...
<queries>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:mimeType="*/*" />
    </intent>
...
</queries>```

Saved my day

Solved!

@faizanbuggy Add following query into your manifest. It's working for me with 30th API version.

...
<queries>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:mimeType="*/*" />
    </intent>
...
</queries>```

Saved my day

did same but issue not resolved

Thank you @slava-the-skills

 <queries>
 <intent>
     <action android:name="android.intent.action.VIEW" />
     <data android:mimeType="*/*" />
 </intent>

This solution is working only for .pdf and .doc. But not for .ppt or .xlx. What should I do to make it work for all type of files?

@Yandamuri me neither. Any solution about xlsx, ppt or etc in android?

@faizanbuggy Add following query into your manifest. It's working for me with 30th API version.

...
<queries>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:mimeType="*/*" />
    </intent>
...
</queries>```

after adding this my app crash on startup, only display splash screen less than a second (

...

where did you add the code on your manifest?
It should be directly inside the manifest tag

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="<YOUR_PACKAGE_NAME">
   
    <queries>
      <intent>
          <action android:name="android.intent.action.VIEW" />
          <data android:mimeType="*/*" />
      </intent>
    </queries>
    .
    .
    .
    <application>
        .
        .
        .
     </application>
</manifest>

it works for me

I placed it exactly there and the build process gets killed with:

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     MYAPP\android\app\src\main\AndroidManifest.xml:2:3-7:13: AAPT: error: unexpected element <queries> found in <manifest>.

I work with react-native@63.2 and react-native-file-viewer@2.1.4

I tried out some react native versions with this solution and it seems to work with react-native 0.64+ only. So I guess the tag is only supported with gradle version 4+

Maybe add this to the Readme?

Even putting the intent with mimeType within query tag, it still doesn't work.
Still same error message: "No app associated with this mime type"

Does anyone know what I can do?

Which mime type does the file have and which react-native version are you running?

pdf.
Version 64.1, but i just updated to 66.3 and still doesnt' work

@faizanbuggy Add following query into your manifest. It's working for me with 30th API version.

...
<queries>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:mimeType="*/*" />
    </intent>
...
</queries>```

Saved my day

did same but issue not resolved

make sure no space on the filename

Even putting the intent with mimeType within query tag, it still doesn't work. Still same error message: "No app associated with this mime type"

Does anyone know what I can do?

make sure there is no space on the filename

I tried out some react native versions with this solution and it seems to work with react-native 0.64+ only. So I guess the tag is only supported with gradle version 4+

If anyone has the error unexpected element <queries> found in <manifest>, try to upgrade your Gradle Plugin to one of these versions:

  • 3.3.3
  • 3.4.3
  • 3.5.4
  • 3.6.4
  • 4.0.1

Source: https://stackoverflow.com/a/62969918/2826279

Even putting the intent with mimeType within query tag, it still doesn't work. Still same error message: "No app associated with this mime type"
Does anyone know what I can do?

make sure there is no space on the filename

This also doesnot work for me

I installed Google Docs, Google Sheets, Google Slides and edit AndroidManifest.xml

<queries>
   <package android:name="com.google.android.apps.docs.editors.docs" /> <!-- package names of Google Docs -->
   <package android:name="com.google.android.apps.docs.editors.sheets" /> <!-- package names of Google Sheets -->
   <package android:name="com.google.android.apps.docs.editors.slides" /> <!-- package names of Google Slides -->
   <intent>
     ...
   </intent>
 </queries>

This is works for me.