chazefate chazefate - 2 months ago 12
Android Question

Getting error when building RN

I am trying to upload image to firebase storage with react native. I fail in very beginning. I am near the end of my game project and this is only part that is missing.

I have added

new ImagePickerPackage(),
new RNFetchBlobPackage()


and also

import com.imagepicker.ImagePickerPackage;
import com.RNFetchBlob.RNFetchBlobPackage;


to MainApplication.java

Every time I run react-native run-android then I get this message:


C:\Users\Hai\Desktop\projectHQ2\HaalariQuiz\android\app\src\main\java\com\manager\MainApplication.java:7:
error: package com.imagepicker does not exist import
com.imagepicker.ImagePickerPackage;

^ C:\Users\Hai\Desktop\projectHQ2\HaalariQuiz\android\app\src\main\java\com\manager\MainApplication.java:8:
error: package com.RNFetchBlob does not exist import
com.RNFetchBlob.RNFetchBlobPackage;

^ C:\Users\Hai\Desktop\projectHQ2\HaalariQuiz\android\app\src\main\java\com\manager\MainApplication.java:30:
error: cannot find symbol
new ImagePickerPackage(),

^ symbol: class ImagePickerPackage

C:\Users\Hai\Desktop\projectHQ2\HaalariQuiz\android\app\src\main\java\com\manager\MainApplication.java:31:
error: cannot find symbol
new RNFetchBlobPackage()


I just cannot understand the error or what I am doing wrong.

Answer Source

Besides adding the dependencies to MainApplication.java, you also need to add to build.gradle and settings.gradle. Follow https://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package to link the package for android. Follow https://github.com/react-community/react-native-image-picker/blob/develop/README.md#install for image picker