React-native-image-picker: [Android] Could not invoke .launchImageLibrary (no virtual method requestPermissions)

Created on 21 Nov 2018  路  4Comments  路  Source: react-native-image-picker/react-native-image-picker

Description

I followed installation guide. Everything works fine on iOS but it breaks on Android. Here's my AndroidManifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.package">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <provider
          android:name="com.imagepicker.FileProvider"
          android:authorities="${applicationId}.provider"
          android:exported="false"
          android:grantUriPermissions="true">
          <meta-data
              android:name="android.support.FILE_PROVIDER_PATHS"
              android:resource="@xml/provider_paths" />
      </provider>
    </application>
</manifest>

I even added provider paths based on other solutions:

<?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="."/> </paths>

How to repeat issue and example

When ImagePicker.launchCamera or ImagePicker.launchImageLibrary is triggered, device asks for permission. After accepting, error screen with this message pops up:

Could not invoke ImagePickerManager.launchImageLibrary

null

No virtual method
requestPermissions([Ljava/lang/String;I)V in class Landroid/app/Activity; or its super classes (declaration of 'android.app.Activity' appears in /system/framework/framework.jar)

Additional Information

  • React Native version: [0.57.5] (same error with every RN version >= 0.55)
  • Platform: [Android] - Tested on Android 5,6,7,8 (real devices)
  • Development Operating System: [Linux and macOS]
  • Dev tools: [Android Studio 3.2.1]
stale

All 4 comments

same error.

Please add
<!--<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />-->permission too.
Its working for me now..

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kariasbolster picture kariasbolster  路  3Comments

kayosouza picture kayosouza  路  4Comments

emmaielle picture emmaielle  路  4Comments

dlochynski picture dlochynski  路  4Comments

Gnative picture Gnative  路  3Comments