When I run npx react-native run-android in my React Native project I receive the following error in my local terminal:
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
5 actionable tasks: 5 up-to-date
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/Users/jacksaunders/gymzoo/android/app/build.gradle' line: 85
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not open cp_dsl generic class cache for script '/Users/jacksaunders/gymzoo/node_modules/react-native/react.gradle' (/Users/jacksaunders/.gradle/caches/7.5.1/scripts/iw3zdgivw8z53seb2tteei08).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 14s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/Users/jacksaunders/gymzoo/android/app/build.gradle' line: 85
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not open cp_dsl generic class cache for script '/Users/jacksaunders/gymzoo/node_modules/react-native/react.gradle' (/Users/jacksaunders/.gradle/caches/7.5.1/scripts/iw3zdgivw8z53seb2tteei08).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 14s
at makeError (/Users/jacksaunders/gymzoo/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /Users/jacksaunders/gymzoo/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Users/jacksaunders/gymzoo/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/jacksaunders/gymzoo/node_modules/#react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
I can see from this error, that it is saying that there is an error on line 85 of my build.gradle
apply from: "../../node_modules/react-native/react.gradle"
Also, I can see that the second task says that the compileSdk is not specified. However, when I search for this throughout my project I can see that in my 'android/build.gradle' I have:
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
and in my app/build.gradle I have:
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.gymzoo"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
I am unsure consequently what this means (or what I am doing wrong/missing). I have tried to ./gradlew clean in the android folder. But it actually just repeats the same error.
edit: after looking at this even more... I feel like it could be something to do with jdk. Tried switching to jdk 8 with export JAVA_HOME=/usr/libexec/java_home -v 1.8 but I don't think that worked because I get
Execution failed for task ':react-native-gradle-plugin:compileKotlin'.
Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property
'compilerRunner$kotlin_gradle_plugin'.
Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilation is running on a JDK, not
JRE.
Related
The project is made with ionic 3, when I try to generate the apk I get this error, I don't know what approach to use to deal with this problem please I need your help. Here is the error I get, I tried several alternatives but no success, the version of graddle is there 7.1
> Task :app:checkReleaseAarMetadata FAILED
> Task :app:bundleReleaseResources FAILED
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (33) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-28).
Dependency: androidx.appcompat:appcompat-resources:1.6.0-rc01.
AAR metadata file: /home/roosvelt/.gradle/caches/transforms-3/2166b563575881abf26d682bf5e7b40b/transformed/jetified-appcompat-resources-1.6.0-rc01/META-INF/com/android/build/gradle/aar-metadata.properties.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:bundleReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2ProcessResourcesRunnable
> Android resource linking failed
ERROR:/home/roosvelt/.gradle/caches/transforms-3/8e2876a9a5ebb578738285d001baa267/transformed/core-1.9.0/res/values/values.xml:104:5-113:25: AAPT: error: resource android:attr/lStar not found.
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 41s
25 actionable tasks: 25 executed
Command failed with exit code 1: /home/roosvelt/Documents/Dev/Perso/freevigile-master/platforms/android/gradlew :app:bundleRelease -b /home/roosvelt/Documents/Dev/Perso/freevigile-master/platforms/android/build.gradle
Error: Command failed with exit code 1: /home/roosvelt/Documents/Dev/Perso/freevigile-master/platforms/android/gradlew :app:bundleRelease -b /home/roosvelt/Documents/Dev/Perso/freevigile-master/platforms/android/build.gradle
at makeError (/home/roosvelt/Documents/Dev/Perso/freevigile-master/node_modules/cordova-android/node_modules/execa/lib/error.js:60:11)
at handlePromise (/home/roosvelt/Documents/Dev/Perso/freevigile-master/node_modules/cordova-android/node_modules/execa/index.js:118:26)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async ProjectBuilder.build (/home/roosvelt/Documents/Dev/Perso/freevigile-master/node_modules/cordova-android/lib/builders/ProjectBuilder.js:316:20)
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release --verbose exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
ionic:utils-process onBeforeExit handler: running 2 functions +0ms
ionic:utils-process processExit: exiting (exit code: 1) +268ms
native and am having trouble building my android version which is giving me the error bellow and i couldnt find anything about it with the newer versions of react-native-webview
ty in advance
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'D:\Users\Volxen\Desktop\port\tv\node_modules\react-native-webview\android\build.gradle' line: 35
* What went wrong:
A problem occurred evaluating project ':react-native-webview'.
> Failed to apply plugin 'kotlin-android'.
> Malformed \uxxxx encoding.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-webview'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
My flutter project runs fine with Firebase ML Vision 0.9.x, if I try to upgrade to 0.10.0 (or higher), it yields the following errors:
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\...\Cache\hosted\pub.dartlang.org\firebase_ml_vision-0.10.0\android\build.gradle' line: 26
* What went wrong:
A problem occurred evaluating project ':firebase_ml_vision'.
> Could not find the firebase_core FlutterFire plugin, have you added it as a dependency in your pubspec?
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':firebase_ml_vision'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 889ms
Exception: Gradle task assembleDebug failed with exit code 1
The first of those two errors is weird because the setup instructions and the package install guidelines both say that firebase_core is not required (anymore).
The second is just plain wrong, as my app's build.gradle specifies compileSdkVersion 30 and the firebase_ml_vision package's build.gradle specifies compileSdkVersion 29.
Any ideas what's going on?
Found a solution that works:
Ignore the setup instructions and add firebase_core as a dependency. Then, add the 'implementations' according to this thread to solve the 'Duplicate class' issues.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
Could not resolve com.android.tools.build:aapt2:3.6.0-6040484.
Required by:
project :app
No cached version of com.android.tools.build:aapt2:3.6.0-6040484 available for offline mode.
No cached version of com.android.tools.build:aapt2:3.6.0-6040484 available for offline mode.
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 267ms
5 actionable tasks: 1 executed, 4 up-to-date
Go to settings/build, execution, Deployment/ gradle/ and uncheck offline work and run build again
If all the think is best but not work you add this line
defaultConfig {
applicationId "com.sendpulse.sendpulse"
minSdkVersion 15
targetSdkVersion 21
multiDexEnabled true //Add me//
}
> Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'npx.cmd'' finished with non-zero exit value 1
* 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 1m 33s
1 actionable task: 1 executed
It seems it's a problem with your build.gradle version at root :
1-Open Android Studio
2-Open the android folder of you project
3-android studio will upgrade the gradle version automatically (make sure it does)
4-try again to generate apk