React Native - react-native-camera error building on Android - react-native

I've been struggling with this all day.
I did the same thing that the repo says.
I ran:
npm install react-native-camera --save
react-native link react-native-camera
The output said that everything was linked correctly.
But when I do:
react-native run-android
I get this error:
\MainApplication.java:6: error: package org.reactnative.camera does
not exist import org.reactnative.camera.RNCameraPackage;
^
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
That's not the entire error, I think that's just the most relevant part of it.
Any hand?

Insert the following lines inside the dependencies block in android/app/build.gradle:
compile (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
compile 'com.android.support:exifinterface:25.+'
compile ('com.google.android.gms:play-services-vision:12.0.1') {
force = true
}
}
You may need to use different exifinterface versions, e.g. 27.+ instead of 25.+.
https://github.com/react-native-community/react-native-camera
4th step on manual installation on android.

Related

Could not resolve all files for configuration ':package-remaster:debugCompileClasspath'

Im building a npm package for react-native, im using a .aar as dependecy, when rebuild the project in android studio no error, problem is when i install it in my react native project and build the apk with eas, im getting the error:
* What went wrong:1140[stderr] Execution failed for task ':package-remaster:generateDebugRFile'.1141[stderr]
> Could not resolve all files for configuration ':package-remaster:debugCompileClasspath'.1142[stderr]
> Failed to transform sdk.aar to match attributes {artifactType=android-symbol-with-package-name}.1143[stderr] > Execution failed for JetifyTransform: /home/expo/workingdir/build/node_modules/package-remaster/libs/sdk.aar.1144[stderr]
> Transform's input file does not exist: /home/expo/workingdir/build/node_modules/package-remaster/libs/sdk.aar. (See https://issuetracker.google.com/issues/158753935)
adding that im using expo with expo prebuild
added this in dependency:
dependencies {
implementation "com.facebook.react:react-native:+"
compileOnly files('../libs/sdk.aar')
}

Running react-native run-android gives error with com.google.android.gms:play-services-iid

Trying to run react-native run-android but this gives me error. The library com.google.android.gms:play-services-iid is being requested by various other libraries at [[16.0.1,16.0.1], [17.0.0,17.0.0]], but resolves to 17.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies
// build.graddle :
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37
com.google.android.gms:play-services-measurement-base is being requested by various other libraries

Trying to uninstall rn-fetch-blob

I am having issues uninstalling.
I have run rm -rf node_modules, yarn and react-native link, and then removed compile project(':rn-fetch-blob') from build.gradle, as other question suggested, but now I am getting more errors in the source code for Android when I try to run react-native run-android (probably will happen for iOS too).
> Task :app:compileDebugJavaWithJavac FAILED
/.../MainApplication.java:6: error: package com.RNFetchBlob does not exist
import com.RNFetchBlob.RNFetchBlobPackage;
^
/.../MainApplication.java:29: error: cannot find symbol
new RNFetchBlobPackage(),
^
symbol: class RNFetchBlobPackage
2 errors
I need help. This module feels like malware.
Best bet is to look at the manual installation steps for rn-fetch-blob and do the opposite of what they are saying
https://github.com/joltup/rn-fetch-blob/blob/master/README.md#user-content-installation
Manual installation instructions
https://github.com/joltup/rn-fetch-blob/wiki/Manually-Link-Package#index
I exactly did the opposite of installation and it worked

Android build fails after flavor is added

I have a react native application ready for the release, after following the android documentation and have added flavors to the product
flavorDimensions "version"
productFlavors {
free {
dimension "version"
applicationId 'com.my-app.free'
}
}
The command react-native run-android fails the gradle build with the following error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-appboy-sdk:transformClassesWithDexForDebugAndroidTest'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
Considerations
If I comment the flavor in the gradle file the command runs without any problem.
Even with this error, I can assemble the apk without any errors using the command ./gradlew assembleRelease.
I can run the app using the android studio run configuration without any errors, this seems to be related to adding flavors and running with the react-native command
Please add below code in your android/build.gradle file, hope it will help you:
android {
dexOptions {
preDexLibraries = false
}
}
Also try below command if above not working:
react-native run-android --variant=developmentDebug

Execution failed for task ':react-native-pjsip:compileReleaseJavaWithJavac'

I'm trying to build a react-native project cloned from github. Here is the github project.
After npm install. I tried the react-native run-android and I got this:
/var/www/html/test/sipsip/react-native-pjsip-app/node_modules/react-native-pjsip/android/src/main/java/com/carusto/ReactNativePjSip/PjSipModulePackage.java:12: error: PjSipModulePackage is not abstract and does not override abstract method createJSModules() in ReactPackage
public class PjSipModulePackage implements ReactPackage {
^
/var/www/html/test/sipsip/react-native-pjsip-app/node_modules/react-native-pjsip/android/src/main/java/com/carusto/ReactNativePjSip/PjActions.java:307: error: cannot find symbol
value.put(mapKey, map.getArray(mapKey).toArrayList());
^
symbol: method toArrayList()
location: interface ReadableArray
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
:react-native-pjsip:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-pjsip:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 24.355 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
I've tried many solutions but none of them solved my issue. Do you have any idea how to fix this?
Additional info:
react-native version:
react-native-cli: 2.0.1
react-native: 0.41.2
I was facing the same problem today, and was solved just updating my react-native in the project using
react-native-git-upgrade
If you don't have it installed yet (the upgrader), you can call
npm install -g react-native-git-upgrade
Of course, there were some thousands of graddles to update, and .js files failing (Still working on it), but at least, I've passed the failure you described.
Delete /ios and /android folders
Then run react-native eject