Cannot run android with react-native-camera [duplicate] - react-native

This question already has answers here:
React Native Android build failure with different errors without any changes in code for past days due to publish of React Native version 0.71.0-rc.0
(4 answers)
Closed 3 months ago.
I can't run project when install this lib.
I got error:
What went wrong:
Execution failed for task ':react-native-camera:generateGeneralDebugRFile'.
Could not resolve all files for configuration ':react-native-camera:generalDebugCompileClasspath'.
Failed to transform react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for JetifyTransform: /Users/chien/.gradle/caches/modules-2/files-2.1/com.facebook.react/react-native/0.71.0-rc.0/7a7f5a0af6ebd8eb94f7e5f7495e9d9684b4f543/react-native-0.71.0-rc.0-debug.aar.
> Java heap space
I tried install by docs:
missingDimensionStrategy 'react-native-camera', 'general' <-- add this line in android/app/build.gradle
Some time ago I was still able to run my project normally. But since yesterday, I can't run anymore
Can anyone help me!

it is java heap space error, try increasing heap space by adding this to gradle.properties
org.gradle.jvmargs=-Xmx2g -XX\:MaxHeapSize\=4g

Related

Detox build failed - ':react-native-inappbrowser-reborn:mergeDebugAndroidTestJavaResource'

I have a problem with building tests in detox. It shows me this error:
What went wrong:
Execution failed for task ':react-native-inappbrowser-reborn:mergeDebugAndroidTestJavaResource'.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path 'META-INF/kotlin-stdlib-jdk8.kotlin_module' from inputs:
- /home/sp/.gradle/caches/transforms-3/4f539c328e5bb19593050e3384e51919/transformed/jetified-kotlin-stdlib-jdk8-1.4.10.jar
- /home/sp/.gradle/caches/transforms-3/c1d521098bb09d070895b1fa3c6468bd/transformed/jetified-kotlin-stdlib-1.8.0.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
I've tried almost everything I found on the forums:
kotlin.stdlib.jdk.variants.version.alignment=false
exclude("META-INF/kotlin-stdlib-common.kotlin_module")
exclude("META-INF/kotlin-stdlib-jdk7.kotlin_module")
exclude("META-INF/kotlin-stdlib-jdk8.kotlin_module")
exclude("META-INF/kotlin-stdlib.kotlin_module")
exclude("kotlin/annotation/annotation.kotlin_builtins")
exclude("kotlin/collections/collections.kotlin_builtins")
exclude("kotlin/coroutines/coroutines.kotlin_builtins")
exclude("kotlin/internal/internal.kotlin_builtins")
exclude("kotlin/kotlin.kotlin_builtins")
exclude("kotlin/ranges/ranges.kotlin_builtins")
exclude("kotlin/reflect/reflect.kotlin_builtins")
etc...
I got this error after adding: implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) - > in app/build.gradle
I had to add this line because the whole application was not building. After adding this line, the problem discussed above started to appear in detox
Thank you very much for your help

D8: Program type already present: androidx.renderscript.Allocation$1

I have a react-native application, using RN 0.62.2, that is working properly.
When trying to use hermes instead of JSC, I am getting the following error during build:
D8: Program type already present: androidx.renderscript.Allocation$1
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Program type already present: androidx.renderscript.Allocation$1
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Any idea what to do?
Have you tried running cd android && ./gradlew clean after switching from jsc to hermes, as the docs suggest (https://reactnative.dev/docs/hermes)?

React native link fails with no package found

I'm not sure what exactly is happening but I am unable to run react-native link without errors occuring
CLI Output:
react-native link --verbose
debug Available platforms: iOS, Android
debug Targeted platforms: iOS, Android
debug Getting project config for iOS...
debug Getting project config for Android...
error No package found. Are you sure this is a React Native project?
error Unexpected close tag
Line: 22
Column: 24
Char: >
debug Error: Unexpected close tag
Line: 22
Column: 24
Char: >
at error (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:666:10)
at strictFail (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:692:7)
at closeTag (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:885:9)
at SAXParser.write (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/node_modules/sax/lib/sax.js:1447:13)
at new XmlDocument (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/xmldoc/lib/xmldoc.js:199:15)
at readManifest (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/tools/android/readManifest.js:44:10)
at Object.projectConfig (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/tools/android/index.js:66:46)
at Object.keys.forEach.platform (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/commands/link/getProjectConfig.js:25:62)
at Array.forEach (<anonymous>)
at getProjectConfig (/Users/Dellybro/Desktop/App/AppReactNativeApp/node_modules/#react-native-community/cli/build/commands/link/getProjectConfig.js:22:35)
This randomly started happening after attempting to npm install react-native-firebase.
What I've tried
clear-caches
remove node_modules and npm install
Checking out my code back to a previous commit
Adding my package name to the manifest locaed in /android/app/src/debug/AndroidManifest.xml
Removing the app from my computer and cloning it from github
Running react-native link on another project, which works, but i just can't run react-native link on this specific project.
So the answer to my question was that in my android manifest xml file, there was an incorrect closing brace for one of my intent filters.
So for anyone that this happens to ensure that all of your Android files have correct syntax.
I fixed this problem by closing some unclosed tag in android/app/src/main/androidManifest.xml. Try checking the file line by line.

React Native Android fails: error 3

Hope you could help me here:
I'm currently building an app which I created through CRNA and then ejected. I get the ios version right on but I'm currently struggling a lot with the android version.
When running react-native run-android all I can get is the following error:
Error type 3
Error: Activity class {com.myapp/com.myapp.MainActivity} does not exist.
I've checked app/build.gradle, app/src/main/AndroidManifest.xml, app/src/main/java/com/myapp/MainActivity.java and app/src/main/java/com/myapp/MainActivity.java for name errors on package. I've tried moving from com.myapp to com.mebius.myapp and com aswell.
Seems this comes from the only plugin I'm using. I'm keeping on the investigation
Any hints?
There are 3 possible reasons for the android app build fails to make
1. You need to define sdk path in android/local.properties
if local.properties doesn't place then make a file names with that
add
sdk.dir = home/user/AndroidApp/local/Sdk
You can match with their system path..
2. Your genymotion or avd must enable with the android studio
3. You must have to go with the following command
npm start
in new terminal .
Please go through with it.
Thanks
Actually I had a problem with my gradle config which look like:
include ':react-native-sensors'
project(':react-native-sensors').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensors/android')
rootProject.name = 'accelapp'
I needed to add: include ':app'
I don't know if it's due to the process of ejecting from CRNA or if it's due to react-native link react-native-sensors though.
EDIT After some investigation, I couldn't reproduce this issue. This leads me to say it was a faulty copy/paste...

calabash-android run app-debug.apk throws exception

I am trying to run calabash-android to test my app, but I get the following error, the same app without any modification was working before I tried to do some modifications, but then I reverted all the modifications to the app :
Exception occurred while dumping:
java.lang.IllegalArgumentException: Unknown package: com.bitbar.testdroid
at com.android.server.pm.Settings.isOrphaned(Settings.java:4134)
at com.android.server.pm.PackageManagerService.isOrphaned(PackageManagerService.java:18091)
at com.android.server.pm.PackageManagerService.deletePackage(PackageManagerService.java:15508)
at com.android.server.pm.PackageInstallerService.uninstall(PackageInstallerService.java:888)
at com.android.server.pm.PackageManagerShellCommand.runUninstall(PackageManagerShellCommand.java:792)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:118)
at android.os.ShellCommand.exec(ShellCommand.java:94)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:18349)
at android.os.Binder.shellCommand(Binder.java:468)
at android.os.Binder.onTransact(Binder.java:367)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2387)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:3031)
at android.os.Binder.execTransact(Binder.java:565)
And then
Success
Success
Scenario: I can choose a file from the Gallery # features/my_first.feature:3
HTTPClient::KeepAliveDisconnected: Connection reset by peer # io_fillbuf - fd:8 (HTTPClient::KeepAliveDisconnected)
./features/support/app_life_cycle_hooks.rb:5:in `Before'
When I take a screenshot # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9
Then I take a screenshot # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9
Failing Scenarios:
cucumber features/my_first.feature:3 # Scenario: I can choose a file from the Gallery
1 scenario (1 failed)
2 steps (2 skipped)
0m6.240s
Exception ScreenShot
I solved the problem by running the build using the gradle task :app:assembleDebug
in the exception above, calabash can't find the package name, because it is on another dex class.
I think in calabash, they may be having problem with multidex projects, and Android Studio will always enable multidex to your app, even if it doesn't need it.
I am not an expert, any suggestion are welcome, and I hope some people can benefit from this answer.