I cloned a react-native project from github and below are the steps that I followed in order to make it work on my local ubuntu 20.04 machine:
(The project was expo managed earlier, but now it is ejected because there are android and ios folders)
created my local feature branch -> git checkout -b feature
installed all the packages in package.json -> yarn install
ran npx react-native run-android to run the app on android emulator
1st Encountered error:-
Could not write standard input to Gradle build daemon.
java.io.IOException: Stream closed
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please read the following process output to find out more:
-----------------------
Unrecognized VM option 'MaxPermSize=512m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
In order to solve this issue, I used this https://stackoverflow.com/a/69630720/11685381 answer and removed -XX:MaxPermSize=512m from my gradle.properties
2nd Encountered error:-
Again used npx react-native run-android and ran into another build error:-
* What went wrong:
Could not open settings generic class cache for settings file '/home/user/project/android/settings.gradle' (/home/user/.gradle/caches/6.9/scripts/5bii70nilhgbvb8zyo7v963b7).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61
To fix this, I used this solution: https://www.codegrepper.com/code-examples/whatever/BUG!+exception+in+phase+'semantic+analysis'+in+source+unit+'_BuildScript_'+Unsupported+class+file+major+version+61
3rd Encountered error:-
Again ran npx react-native run-android and ran into these 2 build error this time:
1: Task failed with an exception.
-----------
* Where:
Build file '/home/user/project/node_modules/expo-gl-cpp/android/build.gradle' line: 307
* What went wrong:
Default side-by-side NDK installation is not found.
Set $ANDROID_NDK_HOME environment variable correctly or setup ndk.dir in local.properties.
> NDK is not installed
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> compileSdkVersion is not specified. Please add it to build.gradle
To solve the 1st issue i.e. NDK is not installed (it is installed though), I created a local.properties inside project/android directory and pasted the following path:
sdk.dir=/home/user/Android/Sdk
ndk.dir=/home/user/Android/Sdk/ndk/24.0.8215888
4th Encountered error:-
> Task :app:generatePackageList FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
* Where:
Script '/home/user/project/node_modules/#react-native-community/cli-platform-android/native_modules.gradle' line: 131
* What went wrong:
Execution failed for task ':app:generatePackageList'.
> argument type mismatch
To solve this, I tried this solution: https://stackoverflow.com/a/68180959/11685381 but this again downloaded the gradle 6.9 which I had earlier also, and again to the 2nd Encountered error
I've been doing this since 2 days, can someone please help me out here what am I doing wrong?
Try updating build.grade from
classpath("com.android.tools.build:gradle:3.5.3")
To
classpath("com.android.tools.build:gradle:3.5.4")
It's just an example. try to update Gradle.
Related
All of sudden my flutter android project build is failing with the following errors.
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class org.bouncycastle.LICENSE found in modules jetified-bcprov-jdk15on-1.65 (org.bouncycastle:bcprov-jdk15on:1.65) and jetified-bcprov-jdk15to18-1.69 (org.bouncycastle:bcprov-jdk15to18:1.69)
2: Task failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
More than one file was found with OS independent path 'org/bouncycastle/x509/CertPathReviewerMessages_de.properties'.
My gradle properties :
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Target and compile SDK's are 31. "com.android.tools.build:gradle:4.1.3"
Flutter configuration:
Flutter 3.3.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ffccd96b62 (4 weeks ago) • 2022-08-29 17:28:57 -0700
Engine • revision 5e9e0e0aa8
Tools • Dart 2.18.0 • DevTools 2.15.0
Edit:
This issue has been fixed,
find the image in the github url:
https://github.com/idnow/de.idnow.android/issues/60
OR
https://user-images.githubusercontent.com/44612915/128930010-79deba97-53ff-4b75-99a0-5a22a6a55296.png
Im also getting the same error
but the thing is I havent pushed the code on my git over a week.
It was working fine, Ive just ran it again after a week with same settings.
Even a month ago code having the same error
Fvm Flutter Version 3.3.0 | 3.0.3
1: Task failed with an exception.
Execution failed for task ':app:checkDebugDuplicateClasses'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class org.bouncycastle.LICENSE found in modules jetified-bcprov-jdk15on-1.65 (org.bouncycastle:bcprov-jdk15on:1.65) and jetified-bcprov-jdk15to18-1.69 (org.bouncycastle:bcprov-jdk15to18:1.69)
...
2: Task failed with an exception.
Execution failed for task ':app:mergeDebugJavaResource'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
More than one file was found with OS independent path 'org/bouncycastle/x509/CertPathReviewerMessages_de.properties'.
I am also getting the following error
Duplicate class org.bouncycastle.LICENSE found in modules jetified-bcprov-jdk15on-1.65 (org.bouncycastle:bcprov-jdk15on:1.65) and jetified-bcprov-jdk15to18-1.69 (org.bouncycastle:bcprov-jdk15to18:1.69)
but in react-native.
My gradle properties :
org.gradle.jvmargs=-Xmx4096m android.useAndroidX=true android.enableJetifier=true
Target and compile SDK's are 31. "com.android.tools.build:gradle:4.2.2"
This is the error I get from the console of the program and it won't let me even import the gradle to Eclipse
Generating app in C:\Users\mrgnh\Desktop\libGDXstuff
Executing 'C:\Users\mrgnh\Desktop\libGDXstuff/gradlew.bat clean --no-daemon'
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/6.7.1/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
FAILURE: Build failed with an exception.
Where:
Settings file 'C:\Users\mrgnh\Desktop\libGDXstuff\settings.gradle'
What went wrong:
Could not compile settings file 'C:\Users\mrgnh\Desktop\libGDXstuff\settings.gradle'.
startup failed:
General error during semantic analysis: Unsupported class file major version 60
It turns out I am blind and that libGDX does not support JDK 16 only 8-15
So when creating the gradle with the JDK 16 gradle System it wasn't working out
Try to change to latest gradle website version of gradle in file: Gradle -> Wrapper -> gradle-wrapper.properties
It helped me.
Whenever I try to run 'react-native run-android'
I got failure:
Execution failed for task ':app:packageDebug'
I tried checkout to previus commits.
I tried removing android/app/build and re-build
I tried removing debug.keystore and initiated it again.
none of them solved the problem.
I successfully run my app before in android virtual device, and I've already uploaded my app to google play store, and it works.
I haven't seen this error before. My code worked totally fine before:
I removed some font files in android/src/main/assets/fonts. This maybe the reason.
I ran "react-native run-ios". This may be the reason.
Task :app:packageDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
117 actionable tasks: 5 executed, 112 up-to-date
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:packageDebug'.
4 exceptions were raised by workers:
java.io.UncheckedIOException: java.io.IOException: Execution of compression failed.
java.io.UncheckedIOException: java.io.IOException: Execution of compression failed.
java.io.UncheckedIOException: java.io.IOException: Execution of compression failed.
java.io.UncheckedIOException: java.io.IOException: Execution of compression failed.
BUILD FAILED in 22s
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (/Users/leonkong/Desktop/dev/CoddingHippo/Native_Makkcha/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
at buildAndRun (/Users/leonkong/Desktop/dev/CoddingHippo/Native_Makkcha/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/Users/leonkong/Desktop/dev/CoddingHippo/Native_Makkcha/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
Build Success message. And running app on virtual device by android studio 2
Clean Gradle
cd android
./gradlew clean
I just restarted my computer and ran ./gradlew assembleRelease again in the project's android folder and it worked.
I also face issue.
I just open Android Studio - Clear Build - Run app.
Works for me
I followed these steps
Uninstall app from emulator
Remove build from android
Run ./gradlew clean in android
Run react-native start --reset-cache
Run react-native run-android
It worked for me
I would like to create a splash screen in my React Native app (not Expo) using Android Studio's emulator.
I was trying to add a splash_screen.xml file into android/app/src/main/res/drawable folder. When I put a new .xml file into the android folder the React compiler shows the following error message:
iMac:newtest Dora$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Configure project :app
WARNING: The specified Android SDK Build Tools version (28.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '28.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Task :app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
com.android.build.gradle.tasks.ResourceException (no error message)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 2s
9 actionable tasks: 1 executed, 8 up-to-date
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/getting-started.html
Command failed: ./gradlew installDebug
Error: Command failed: ./gradlew installDebug
at checkExecSyncError (child_process.js:637:11)
at Object.execFileSync (child_process.js:655:13)
at runOnAllDevices (/Users/Dora/Documents/code/react native/newtest/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
at buildAndRun (/Users/Dora/Documents/code/react native/newtest/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
at isPackagerRunning.then.result (/Users/Dora/Documents/code/react native/newtest/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
Thank you for taking your time to help me to solve this issue!
Cheers,
Alex
Well, finally I have managed to solve this issue. It is for those who will encounter this problem during Android development.
So, what i did exactly:
1. cd into android folder and run this: ./gradlew installDebug
After this command finished without any errors
go back to the root directory and start the app using: react-native run-android
Conclusion, if you add or change any xml files in android folder, you have to do the above procedure.
That's all!
Alex
I have been trying to do CI using Jenkins for my Android application. I am new to this. After following some of the tutorials, I am able to atleast set up and run the build now option. It download every pom required but while building it give below error.
============================================
C:\Windows\System32\config\systemprofile.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\e796469c387c11565d873216f24c3b6f\res\drawable\abc_ic_go_search_api_material.xml: error: file not found.
C:\Windows\System32\config\systemprofile.gradle\caches\transforms-1\files-1.1\play-services-base-15.0.1.aar\7207fbd3bdb6cb696445cfc77c16e5ed\res\drawable-hdpi-v4\googleg_standard_color_18.png: error: file not found.
C:\Windows\System32\config\systemprofile.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\e796469c387c11565d873216f24c3b6f\res\layout\select_dialog_singlechoice_material.xml: error: file not found.
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
======================================================
Can you please let me know how to resolve it?
Do let me know if anything else is required.
Maybe the path is too long. Try this:
Jenkins --> Project --> Project Configuration --> Build
Select advanced option
Check the option box "Force GRADLE_USER_HOME to use workspace"
Build your project
I solved my problem by this way, good luck!
Try updating your android gradle plugin version to 3.2.0-alpha12 or newer. AAPT2's version included in these versions contains many fixes for path support on Windows which resulted in similar errors.
you can solve this by separating into smaller group of task
make separate invoke gradle script under build tab
clean build assembleDebug
test
connectedAndroidTest
i had similar issues, when i ran assembleDebug and test together in Jenkins as a single task
When using Jenkins with Window to build Android, I face this problem myself.
I fix by add GRADLE_USER_HOME to Environment Variable:
GRADLE_USER_HOME = C:\Users\*MyUserName*\.gradle
hope this help,