Getting error when building RN - android

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.

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

Related

Error: cannot find symbol import com.google.android.gms.ads.InterstitialAd

I had added google AdMob to the project and found this error :
error: cannot find symbol
import com.google.android.gms.ads.InterstitialAd;
^
symbol: class InterstitialAd
location: package com.google.android.gms.ads
I found the answer :
add this codes to build.gradle(app)
(in the android tag )
configurations.all {
resolutionStrategy {
force "com.google.android.gms:play-services-basement:17.0.0"
force "com.google.android.gms:play-services-base:17.1.0"
force "com.google.android.gms:play-services-stats:17.0.0"
force "com.google.android.gms:play-services-gcm:17.0.0"
force "com.google.android.gms:play-services-ads:19.7.0"
}
}
and if you had use of admob in the one library add codes above to library gradle too
If you get this error after updating your com.google.android.gms:play-services-ads dependency to a more recent version, know that importing com.google.android.gms.ads.InterstitialAd has been deprecated since version 19.7.0 and has since been totally removed.
The new import should be:
import com.google.android.gms.ads.interstitial.InterstitialAd;
Either revert com.google.android.gms:play-services-ads to a version pre-19.7.0 or update your code by following the documentation here: https://developers.google.com/admob/android/interstitial.

error: cannot find symbol AppLinks.getTargetUrlFromInboundIntent in com.facebook.android:facebook-android-sdk:11.3.0

While upgrading the facebook SDK from a lowest version(7.1.0) to latest version (11.3.0) got symbol: method getTargetUrlFromInboundIntent(ItemViewActivity,Intent) location: class AppLinks
I have got
error: package bolts does not exist import bolts.AppLinks;
So I have modified and fixed the import error
import bolts.AppLinks; to import com.facebook.bolts.AppLinks;
Now I am getting below error
error: cannot find symbol
AppLinks.getTargetUrlFromInboundIntent(this, getIntent());
^
symbol: method getTargetUrlFromInboundIntent(ItemViewActivity,Intent)
location: class AppLinks
Code:
Uri applinktUrl = AppLinks.getTargetUrlFromInboundIntent(this, getIntent());
It seems that bolts has been removed from within facebook SDK in version 9.0.0 although it's not mentioned in the release notes
https://github.com/facebook/facebook-android-sdk/blob/main/CHANGELOG.md
You could use the dependency directly from it's opensource project
https://github.com/BoltsFramework/Bolts-Android
this would be to add
implementation 'com.parse.bolts:bolts-applinks:1.4.0'
and keep your old import line
import bolts.AppLinks
Having said this, I don't know how and if Applinks is used anymore within Facebook

Error: cannot find symbol variable Constants

How can import util.Constants in
Android Studio 3.0.1
Error:cannot find symbol variable Constants
Alt+enter said me android.provider.SyncStateContract.Constants? But I need to import like
Import mypackage name.until.Constants
delete the Constant usage in the program.
Go to your imports section and enter
import android.provider.SyncStateContract.Constants.ConstantName
This works out.

How to integrate app Invites for Android with Facebook?

I'm quite new to Android and I don't quite understand importing classes so please point me in the right direction. I've added the Facebook SDK to my project via Gradle.
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
In my Java class, I have the following imports:
import com.facebook.FacebookSdk;
import com.facebook.appevents.*;
When I add the following code from this link:
String appLinkUrl, previewImageUrl;
appLinkUrl = "https://www.example.com/myapplink";
previewImageUrl = "https://www.example.com/my_invite_image.jpg";
if (AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.setPreviewImageUrl(previewImageUrl)
.build();
AppInviteDialog.show(this, content);
}
The app throws the following errors:
Error: cannot find symbol variable AppInviteDialog
Error: cannot find symbol variable AppInviteContent
What do I need to import/modify for this to work correctly?
you also need following imports....in general IDEs like Android Studio will give you option to add these imports
import com.facebook.share.model.AppInviteContent;
import com.facebook.share.widget.AppInviteDialog;
If you have already the 2 imports and it won't work, try adding this in your build.gradle of your app:
compile 'com.facebook.android:facebook-android-sdk:4.23.0'

React Native Sqlite for android configuration

I am playing with react native for android and i have special interest with sqlite.
I try to use the sqlite lib here react-native-sqlite-storage buy i always have BUILD FAILED when "run-android". I'm a little lost at step 4 (How to use Android)
configuring the MainActivity
The error:
E:\Documents\Visual Studio CODE\MyApp\android\app\src\main\java\com\myapp\MainActivity.java:22: error: cannot find symbol
protected List getPackages() {
^
symbol: class List
location: class MainActivity
...
Have somebody a very simple sample project for android to see the correct conf?
thanks in advance.
You are missing import statement for the List.
import java.util.List;
#Override
protected List getPackages() {
//noinspection RedundantArrayCreation
return Arrays.asList(new ReactPackage[]{
new MainReactPackage(),
});
}
Any java IDE has some kind of fix import function so it would automatically propose you correct solution.
Try android studio it's free and react-native automatically generate gradle configuration. All you need to do is to import your project folder with gradle files (android by default) into IDE and press ctrl+space to turn IntelliSense on.
You should change MainAplication.java and not MainActivity.java

Categories

Resources