React-Native: Could not resolve project :react-native-gpay - react-native

Hi there I am integrating google pay api using react-native-gpay but I have got an issue
Steps to install react-native-gpay
1- npm i react-native-gpay
2- react-native link react-native-gpay
3- Added in dependency block of android/app/build.gradle compile project(':react-native-gpay')
4- added import com.reactlibrary.RNGpayPackage; in MainActivity.java
5- Replaced getPackages method in MainApplication.java with below code() >
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new RNGpayPackage()); // added a package in the list returned by getPackages()
return packages;
}
and also imported in MainApplication.java import com.reactlibrary.RNGpayPackage;
6- My settings.gradle
rootProject.name = 'Pmt'
include ':react-native-gpay'
project(':react-native-gpay').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gpay/android')
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
I checked on GitHub too to resolve the issue like this
But I couldn't find any answer. I am getting the following issue in my console
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve project :react-native-gpay.
Required by:
project :app
> Unable to find a matching configuration of project :react-native-gpay:
- None of the consumable configurations have attributes.

Related

FAILURE: Build failed with an exception. Could not find com.airbnb.android:lottie:5.1.4 for rn0.70.6

FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
Could not find com.airbnb.android:lottie:5.1.4.
Required by:
My package.json
enter image description here
build.gradle
enter image description here
gradle.properties
enter image description here
I tried to build react native android apk file with command:
cd android
./gradlew clean
./gradlew build
I want to build the file android apk, Please help,
Thank you everyone.
android/build.gradle
add this line to build.gradle and try again
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
if you don't understand this here you can see all chat I have same issue but I add this line to build file and it's working for me
hope this will help you!

How can I import OpenCV library to React-Native project

I tried to import OpenCV via native code but that not worked and I also tried react-native-opencv
library but that library doesn't contain all OpenCV methods.
How can I achieve to use OpenCV in my react-native project?
Thanks in advance.
I have been struggling with OpenCV in react-native for a week now and finally got it working. There is this very good article https://brainhub.eu/blog/opencv-react-native-image-processing/ together with this repo https://github.com/brainhubeu/react-native-opencv-tutorial which describes in details on how to do get it running. However I could not make the code from this repo working by following the steps described or following any other tutorial/video I could find. So in case if anyone is facing the same problem you can try this steps that made the app from the mentioned repo working with OpenCV v4.5 on my Android 10 device.
Open terminal and initialize new React-Native project
npx react-native init NAME_OF_YOUR_PROJECT
Navigate to path /main
cd NAME_OF_YOUR_PROJECT/android/app/src/main
Create new folder named jniLibs
mkdir jniLibs
Download and extract latest OpenCV for Android (tested with OpenCV 4.5) from https://opencv.org/releases/
Rename the "sdk" folder in the extracted folder (OpenCV-android-sdk) to "opencv"
Copy content from extracted folder (OpenCV-android-sdk/opencv/native/libs/) to newly created ./jniLibs
cp -r /PATH_TO_EXTRACTED_OPENCV_FOLDER/OpenCV-android-sdk/opencv/native/libs/ ./jniLibs
Open Android Studio and open Android folder of your projects dir
File -> Open -> select */NAME_OF_YOUR_PROJECT/android
Import OpenCV to your project
File -> New -> Import module -> select the folder you renamed to opencv
(IMPORTANT! Some tutorials say to select the "java" folder inside this folder - don't do that)
Under Gradle Scripts: open build.gradle(:opencv) and build.gradle(YOUR_PROJECT_NAME)
Change both to matching numbers - in my case:
minSdkVersion = 21
compileSdkVersion = 29
Add opencv to projects dependencies
File -> Project Structure -> Dependencies -> select app and press the "+" sign (located "underneath All dependencies") -> check the checkbox next to opencv -> press OK
In build.gradle(YOUR_APP_NAME) change version of gradle to 4.1.0
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Now open build.gradle(Project: NAME_OF_YOUR_PROJECT .app) and change java version in compile options and add packagin option with some pickfirst option. Also enable multidex option and if you wish to use react-native-camera add the missing dimension strategy. Should look something like this:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
}
defaultConfig {
applicationId "com.stackoverflow" // !!! if copy-pasting change applicationId to yours
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'general'
}
Open build.gradle(:opencv) and enable multidex option in default config. If you wish to use react-native-camera then also add missing dimension strategy. Should look something like this
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode openCVersionCode
versionName openCVersionName
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'general'
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
targets "opencv_jni_shared"
}
}
}
Also change the version of java in compile options (must be same as in build.gradle(:app). Should look something like this
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Add the following user permissions to your /PATH_TO_YOUR_PROJECT/android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Open gradle wrapper properties (/PATH_TO_YOUR_PROJECT/android/gradle/wrapper/gradle.properties) and change the version number of gradle
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Go to /YOUR_PROJECT_PATH/android/app/src/main/java/com/ and create reactlibrary folder then create two files inside that folder:
RNOpenCvLibraryModule.java
RNOpenCvLibraryPackage.java
Fill them with the same content as found on this GIT repo https://github.com/brainhubeu/react-native-opencv-tutorial/tree/master/android/app/src/main/java/com/reactlibrary
Open MainApplication.java and add this "packages.add(new RNOpenCvLibraryPackage());" to getPackage() method. Should look something like this:
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new RNOpenCvLibraryPackage()); // ADD THIS
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
Also add this to the onCreate() method:
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
if (!OpenCVLoader.initDebug()) { // ADD THIS
Log.d("OpenCv", "Error while init"); // AND THIS
} // DON'T FORGET THE "}"
}
Dont forget to add proper imports in the begining of your "MainApplication.java"
import org.opencv.android.OpenCVLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
Syncronize your project
File -> Syncronize Your Project with Gradle Files
Open the terminal and navigate to your project. Add this packages
cd /PATH_TO_YOUR_PROJECT/
npm i react-native-easy-toast --save
npm i react-native-svg --save
npm install --save react-native-camera#git+https://git#github.com/react-native-community/react-native-camera.git
(Make sure react-native-camera is installed from GIT repo otherwise you will encounter errors)
Create new folder nammed "src" in your PROJECT_PATH and copy the content of this repos ("https://github.com/brainhubeu/react-native-opencv-tutorial/tree/master/src") "src" folder to yours (/PATH_TO_YOUR_PROJECT/src/)
mkdir src
Copy the content of this repos "https://github.com/brainhubeu/react-native-opencv-tutorial/blob/master/App.js" App.js file and replace the content in your App.js file (located in YOUR_PROJECT_PATH)
Start react-native
npx react-native start
Run on Android device
npx react-native run-android
you can use this lib
react-native-opencv3
or you can exploit this project for using native Java and Objective-C bindings for OpenCV in react-native
If someone is still wondering here's the solution. It is quite some work to just set it up. You will have to write your OpenCV code in Java.
https://stackoverflow.com/a/63116300/10333905
sometimes the while trying to import opencv module, you will not proceed after selecting src directory. both next and finish option will be disabled. for this case.
create a folder "opencv" in the android folder and the copy all the files in the opencv sdk folder into this folder.
in setting.gradle add include ":opencv"
sync now.
goto project structure and add in dependency tab click on '+' icon on top app and select the module dependency and then opencv library.
Note:if the opencv is not present in the module dependency then you have copied the files wrongly. check whether the gralde file present in the files you copied

After Adding new RNAmplitudePackage(MainApplication.this)) to MainApplication.java . Build is failing

import com.sudoplz.reactnativeamplitudeanalytics.RNAmplitudeSDKPackage;
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new RNAmplitudePackage(MainApplication.this))
return packages;
}
MainApplication.java . If possible can anyone share link to integrate amplitude analytics in react-native.
Thank You in advance
If you are using Expo Amplitude is event tracking in build in and you should refer Expo docs.
Any other case official JS SDK has built-in React Native support. You can read more here.

I'm getting trouble with react-native-vector-icons with autolink. It doesn't run anyhow

This is my problem.
A problem occurred configuring project ':react-native-vector-icons'.
Could not resolve all dependencies for configuration ':react-native-vector-icons:classpath'.
Could not load module metadata from C:\Users\erick.gradle\caches\modules-2\metadata-2.71\descriptors\com.android.tools.build\gradle-api\3.3.1\fc7e8eef251519086b6ee9788cba4dd2\descriptor.bin
Please refer to this to see if there are any missing parts.
Edit android/app/build.gradle
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
Edit android/settings.gradle to look like this (without the +):
+ include ':react-native-vector-icons'
+ project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
Edit android/app/build.gradle (note: app folder) to look like
this:
dependencies {
+ implementation project(':react-native-vector-icons')
}
Edit your MainApplication.java (deep in
android/app/src/main/java/...) to look like this (note two places to
edit):
package com.myapp;
+ import com.oblador.vectoricons.VectorIconsPackage;
....
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
+ , new VectorIconsPackage()
);
}
}
in React Native > 0.60, you do not need to link packages manually. All you need is install your package and run link command. for react-native-vector-icons, remove any code and files you added to android or ios manually, or run react-native unlink react-native-vector-icons.
Remember that for ios, you need to get the last update of cocopods. if you have problem again, in ios folder run pod install command.
I hope this can help you.

Gradle failing to resolve PrimeFaces theme dependency: peer not authenticated

I have a Gradle Java project in which I'm using JSF with PrimeFaces.
In order to change it's theme, I added the required dependency in my build.gradle file, which most important parts are configured as follows:
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
sourceCompatibility = 1.8
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Arch Project',
'Implementation-Version': version
}
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://repository.primefaces.org' }
maven { url 'https://repository.jboss.org/nexus/content/groups/public' }
}
configurations {
provided
}
sourceSets {
main.compileClasspath += configurations.provided
test.compileClasspath += configurations.provided
test.runtimeClasspath += configurations.provided
}
dependencies {
/* Cryptography API for BCrypt algorithm. */
compile 'de.svenkubiak:jBCrypt:0.4'
/* Primefaces. */
compile 'org.primefaces:primefaces:5.3'
/* Primefaces pepper grinder theme. */
compile 'org.primefaces.themes:pepper-grinder:1.0.10'
... another few dependencies
}
However, when I run gradle build on the console I get the following error:
C:\Users\bruno.gasparotto\git\archproject\archproject>gradle build
:compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve org.primefaces.themes:pepper-grinder:1.0.10.
Required by:
:archproject:1.0
> Could not HEAD 'https://repository.primefaces.org/org/primefaces/themes/pepper-grinder/1.0.10/pepper-grinder-1.0.10.pom'.
> peer not authenticated
What I've tried and didn't work so far:
Changed the dependency from pepper-grinder to all-themes.
Replaced https with http on PrimeFaces repo configuration in my build.gradle file.
Also, it's important to mention that:
The url https://repository.primefaces.org/org/primefaces/themes/pepper-grinder/1.0.10/pepper-grinder-1.0.10.pom is available if I try to access it through the browser.
I am NOT behind a proxy.
If I remove the pepper-grinder dependency, it works just fine.
The same setup used to work more than year ago, so I believe something new is happening.
Any ideas?
Thanks is advance.