question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🤖 Android build failed: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

See original GitHub issue

Summary

I was using expo build:android but after upgrading to eas-build It is showing me this error :

🤖 Android build failed: Gradle build failed with unknown error. Please see logs for the “Run gradlew” phase.

Environment

{
  "name": "test-app",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/netinfo": "8.2.0",
    "expo": "~45.0.0",
    "expo-asset": "~8.5.0",
    "expo-av": "~11.2.3",
    "expo-splash-screen": "~0.15.1",
    "expo-status-bar": "~1.3.0",
    "expo-system-ui": "~1.2.0",
    "expo-updates": "~0.13.2",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.68.2",
    "react-native-video": "git+https://git@github.com/paddy57/react-native-video-android-cache.git",
    "react-native-web": "0.17.7",
    "react-native-webview": "11.18.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "metro": "^0.71.1"
  },
  "private": true
}

Please specify your device/emulator/simulator platform, model and version

ADB TV OS, Expo SDK

Error output

`Running ‘./gradlew :app:bundleRelease’ in /home/expo/workingdir/build/android Downloading https://services.gradle.org/distributions/gradle-7.3.3-all.zip 10 %. 20 %. 30 %. 40%. 50 %. 60%. 70 %. 80 %. 90%. 100% Welcome to Gradle 7.3.3! Here are the highlights of this release:

Task :react-native-gradle-plugin:compileKotlin ‘compileJava’ task (current target is 1.8) and ‘compileKotlin’ task (current target is 11) jvm target compatibility should be set to the same Java version. w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (10, 37): ‘BaseVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (119, 30): ‘BaseVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (135, 26): ‘BaseVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (155, 32): ‘BaseVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (161, 31): ‘BaseVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (169, 36): ‘BaseVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt: (100, 48): ‘reactRoot: DirectoryProperty’ is deprecated. reactRoot was confusing and has been replace with rootto point to your root project and reactNativeDir to point to the folder of the react-native NPM package w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (10, 37): ‘ApplicationVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (11, 37): ‘BaseVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (12, 37): ‘LibraryVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (28, 51): ‘BaseVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (131, 12): ‘ApplicationVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (132, 12): ‘LibraryVariant’ is deprecated. Deprecated in Java w: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (252, 14): ‘BaseVariant’ is deprecated. Deprecated in Java Task :react-native-gradle-plugin:compileJava [stderr] Note: /home/expo/workingdir/build/node_modules/react-native-gradle-plugin/src/main/java/com/facebook/react/codegen/generator/SchemaJsonParser.java uses or overrides a deprecated API. [stderr] Note: Recompile with -Xlint:deprecation for details. Task :react-native-gradle-plugin:pluginDescriptors Task :react-native-gradle-plugin:processResources Task :react-native-gradle-plugin:classes Task :react-native-gradle-plugin:inspectClassesForKotlinIC Task :react-native-gradle-plugin:jar Configure project :app Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version. Class name for the included build object: org.gradle.composite.internal.DefaultIncludedBuild$IncludedBuildImpl_Decorated. Configure project :expo-av Checking the license for package NDK (Side by side) 21.4.7075529 in /home/expo/Android/Sdk/licenses License for package NDK (Side by side) 21.4.7075529 accepted. Preparing “Install NDK (Side by side) 21.4.7075529 (revision: 21.4.7075529)”. “Install NDK (Side by side) 21.4.7075529 (revision: 21.4.7075529)” ready. Installing NDK (Side by side) 21.4.7075529 in /home/expo/Android/Sdk/ndk/21.4.7075529 “Install NDK (Side by side) 21.4.7075529 (revision: 21.4.7075529)” complete. “Install NDK (Side by side) 21.4.7075529 (revision: 21.4.7075529)” finished. Checking the license for package CMake 3.10.2.4988404 in /home/expo/Android/Sdk/licenses License for package CMake 3.10.2.4988404 accepted. Preparing “Install CMake 3.10.2.4988404 (revision: 3.10.2)”. “Install CMake 3.10.2.4988404 (revision: 3.10.2)” ready. Installing CMake 3.10.2.4988404 in /home/expo/Android/Sdk/cmake/3.10.2.4988404 “Install CMake 3.10.2.4988404 (revision: 3.10.2)” complete. “Install CMake 3.10.2.4988404 (revision: 3.10.2)” finished. Configure project :expo-eas-client Warning: The ‘kotlin-android-extensions’ Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the ‘kotlin-parcelize’ plugin. Configure project :expo-structured-headers Warning: The ‘kotlin-android-extensions’ Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the ‘kotlin-parcelize’ plugin. Configure project :expo-updates-interface Warning: The ‘kotlin-android-extensions’ Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the ‘kotlin-parcelize’ plugin. Configure project :expo Using expo modules

  • expo-application (4.1.0)
  • expo-av (11.2.3)
  • expo-constants (13.1.1)
  • expo-eas-client (0.2.1)
  • expo-error-recovery (3.1.0)
  • expo-file-system (14.0.0)
  • expo-font (10.1.0)
  • expo-json-utils (0.3.0)
  • expo-keep-awake (10.1.1)
  • expo-manifests (0.3.0)
  • expo-modules-core (0.9.2)
  • expo-splash-screen (0.15.1)
  • expo-structured-headers (2.2.1)
  • expo-system-ui (1.2.0)
  • expo-updates (0.13.2) Checking the license for package Android SDK Build-Tools 30.0.2 in /home/expo/Android/Sdk/licenses License for package Android SDK Build-Tools 30.0.2 accepted. Preparing “Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)”. “Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)” ready. Installing Android SDK Build-Tools 30.0.2 in /home/expo/Android/Sdk/build-tools/30.0.2 “Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)” complete. “Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)” finished. Checking the license for package Android SDK Platform 31 in /home/expo/Android/Sdk/licenses License for package Android SDK Platform 31 accepted. Preparing “Install Android SDK Platform 31 (revision: 1)”. “Install Android SDK Platform 31 (revision: 1)” ready. Installing Android SDK Platform 31 in /home/expo/Android/Sdk/platforms/android-31 “Install Android SDK Platform 31 (revision: 1)” complete. “Install Android SDK Platform 31 (revision: 1)” finished. Checking the license for package Android SDK Build-Tools 31 in /home/expo/Android/Sdk/licenses License for package Android SDK Build-Tools 31 accepted. Preparing “Install Android SDK Build-Tools 31 (revision: 31.0.0)”. “Install Android SDK Build-Tools 31 (revision: 31.0.0)” ready. Installing Android SDK Build-Tools 31 in /home/expo/Android/Sdk/build-tools/31.0.0 “Install Android SDK Build-Tools 31 (revision: 31.0.0)” complete. “Install Android SDK Build-Tools 31 (revision: 31.0.0)” finished.

Task :app:generatePackageList Task :app:preBuild Task :app:preReleaseBuild Task :app:bundleReleaseJsAndAssets FAILED Error [ERR_REQUIRE_ESM]: require() of ES Module /home/expo/workingdir/build/metro.config.js from /home/expo/workingdir/build/node_modules/import-fresh/index.js not supported. metro.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains “type”: “module” which declares all .js files in that package scope as ES modules. Instead rename metro.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change “type”: “module” to “type”: “commonjs” in /home/expo/workingdir/build/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). [stderr] error require() of ES Module /home/expo/workingdir/build/metro.config.js from /home/expo/workingdir/build/node_modules/import-fresh/index.js not supported. [stderr] metro.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains “type”: “module” which declares all .js files in that package scope as ES modules. [stderr] Instead rename metro.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change “type”: “module” to “type”: “commonjs” in /home/expo/workingdir/build/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at module.exports (/home/expo/workingdir/build/node_modules/import-fresh/index.js:28:9) at loadJs (/home/expo/workingdir/build/node_modules/cosmiconfig/dist/loaders.js:9:18) at Explorer.loadFileContent (/home/expo/workingdir/build/node_modules/cosmiconfig/dist/createExplorer.js:230:12) at /home/expo/workingdir/build/node_modules/cosmiconfig/dist/createExplorer.js:252:21 info Run CLI with --verbose flag for more details. [stderr] FAILURE: Build failed with an exception. [stderr]

  • What went wrong: [stderr] Execution failed for task ‘:app:bundleReleaseJsAndAssets’. [stderr]

Process ‘command ‘node’’ finished with non-zero exit value 1 [stderr]

  • Try: [stderr]

Run with --stacktrace option to get the stack trace. [stderr] Run with --info or --debug [stderr] option to get more log output. [stderr] Run with --scan to get full insights. [stderr]

  • Get more help at https://help.gradle.org [stderr] BUILD FAILED in 3m 44s 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.3.3/userguide/command_line_interface.html#sec:command_line_warnings 8 actionable tasks: 8 executed Unable to list file systems to check whether they can be watched. The whole state of the virtual file system has been discarded. Reason: Could not query file systems: could not open mount file (errno 2: No such file or directory) Error: Gradle build failed with unknown error. Please see logs for the “Run gradlew” phase.`

Reproducible demo or steps to reproduce from a blank project

`import { StyleSheet, View, Dimensions, Text } from ‘react-native’; import appData from “./data.json” import NetInfo from “@react-native-community/netinfo” import React, { Component } from ‘react’; import * as Updates from “expo-updates” import * as SplashScreen from ‘expo-splash-screen’; import {Asset} from “expo-asset” import { Video } from ‘expo-av’;

var i=0 const data = appData

const {width, height} = Dimensions.get(“screen”)

export default class App extends Component {

constructor(props){ super(props); this.state = { conn_status: “”, playlist: data, } /* this.prepare() this.InternetChecker() this.reactToUpdates() / } cacheResources = async () => { var videosA = data[0].src var dataCached = [] var videosB = data[1].src var videosC = data[2].src console.log(videosA) console.log(videosB) console.log(videosC) const cacheVideosA = Asset.fromModule(videosA).downloadAsync() dataCached.push(cacheVideosA)
const cacheVideosB = Asset.fromModule(videosB).downloadAsync() dataCached.push(cacheVideosB)
const cacheVideosC = Asset.fromModule(videosC).downloadAsync() dataCached.push(cacheVideosC)
console.log(dataCached) /
videos.map(video => { return Asset.fromModule(video).downloadAsync() }) */ return Promise.all(dataCached) }

componentDidMount = () => { loadResource = async () => { await this.cacheResources() await this.prepare() await this.InternetChecker() await this.reactToUpdates() } loadResource() }

reactToUpdates = async () => { Updates.addListener((e)=>{ if (e.type === Updates.UpdateEventType.UPDATE_AVAILABLE) { Updates.reloadAsync() } }) }

prepare = async () => { try { await SplashScreen.preventAutoHideAsync(); await new Promise(resolve => setTimeout(resolve, 3000)); } catch (e) { console.warn(e); } finally { SplashScreen.hideAsync(); } }

InternetChecker = async () => { await NetInfo.fetch().then( state => { console.log(“Connection Type”, state.type) console.log(“Is connected?”, state.isConnected) if(state.isConnected === true){ this.setState({ conn_status: “online” }) } else { this.setState({ conn_status: “offline” }) } }) }

videoUpdated(playbackStatus){ if(playbackStatus[‘didJustFinish’]){ console.log(this.state.playlist[i].name+" just finished",Date().toLocaleString(),i); this.playNext(); } } playNext(){ let playlist = this.state.playlist; let temp = playlist[0]; playlist.shift(); playlist.push(temp); this.setState({playlist,}) this.InternetChecker() } render() { if(this.state.conn_status === “online”){ return ( <View> <Video onPlaybackStatusUpdate={(playbackStatus)=> this.videoUpdated(playbackStatus)} resizeMode=“contain” source={{uri: this.state.playlist[0].src}} useNativeControls = {false} rate={1.0} shouldPlay autoPlay volume={1.0} muted={false} style={{height:height,width:width}} /> </View> ); } else { return( <View> <Video resizeMode=“contain” source={require(“./assets/offline.mp4”)} useNativeControls = {false} rate={1.0} shouldPlay autoPlay isLooping volume={1.0} muted={false} style={{height:height,width:width}} /> </View> ) } } }

const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: ‘#fff’, alignItems: ‘center’, justifyContent: ‘center’, }, }); `

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Spooksancommented, Oct 20, 2022

Fixed this by creating a new file .npmrc in project folder then, setting ‘legacy-peer-deps=true’ and also run ‘npm config set legacy-peer-deps true’ in terminal

3reactions
kaynetpccommented, Oct 5, 2022

Probably dependencies versioning incompatibility

Try run

expo doctor expo doctor --fix-dependencies

then try to rebuild

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradle build failed with unknown error. Please see logs for the ...
You have Three choices to fix this error. Choice 1. Downgrade gradle from android/gradle/wrapper/gradle-wrapper.properties change ...
Read more >
gradle build failed with unknown error. see logs for the "run ...
Error : Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
Read more >
Expo 45 build fail on Android with EAS
expo build or eas build all fails at gradlew stage with below error log ... See logs for the "Run gradlew" phase for...
Read more >
Gradle Build Failed Solution in android studio very easily for ...
In this video I want to show Gradle Build Failed Solution in android studio very easily for beginners in hindi.
Read more >
Android Studio 3.0.1 – Gradlew build failure - Synaptik Labs
The fix for this issue is very straight forward. All you have to do is add Google's build script repository to your configuration....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found