(react-native run-android --variant=release) Error: spawnSync ./gradlew ENOBUFS
See original GitHub issueThis issue has popped up when I try to run my android app with any of my release-based variants. The app runs properly when not specifying a variant (using the debug variant), and I am also able to successfully create release .apk/.aab files as well.
When running npx react-native run-android --variant=release
, the process goes on as normal until it reaches this point:
> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, /app/android/app/build/generated/assets/react/release/index.android.bundle
info Writing sourcemap output to:, /app/android/app/build/intermediates/sourcemaps/react/release/index.android.bundle.packager.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 144 asset files
info Done copying assets
<=======------> 54% EXECUTING [2m 18s]
> IDLE
> IDLE
> IDLE
> :app:bundleReleaseJsAndAssets
> IDLE
> IDLE
> IDLE
> IDLE
after which it will consistently log a giant set of warnings related to the index.android.bundle. Here is an excerpt:
/app/android/app/build/generated/assets/react/release/index.android.bundle:29:134: warning: the variable "Promise" was not declared in function "isBoldTextEnabled"
__d(function(g,r,i,a,m,e,d){'use strict';var n=r(d[0])(r(d[1])),t=r(d[2]),o=r(d[3]),s=new Map,c={isBoldTextEnabled:function(){return Promise.resolve(!1)},isGrayscaleEnabled:function(){return Promise.resolve(!1)},isInvertColorsEnabled:function(){return Promise.resolve(!1)},isReduceMotionEnabled:function(){return new Promise(function(t,o){n.default?n.default.isReduceMotionEnabled(t):o(!1)})},isReduceTransparencyEnabled:function(){return Promise.resolve(!1)},isScreenReaderEnabled:function(){return new Promise(function(t,o){n.default?n.default.isTouchExplorationEnabled(t):o(!1)})},get fetch(){return this.isScreenReaderEnabled},addEventListener:function(n,o){var c;'change'===n||'screenReaderChanged'===n?c=t.addListener("touchExplorationDidChange",function(n){o(n)}):'reduceMotionChanged'===n&&(c=t.addListener("reduceMotionDidChange",function(n){o(n)})),s.set(o,c)},removeEventListener:function(n,t){var o=s.get(t);o&&(o.remove(),s.delete(t))},setAccessibilityFocus:function(n){o.sendAccessibilityEvent(n,o.getConstants().AccessibilityEventTypes.typeViewFocused)},announceForAccessibility:function(t){n.default&&n.default.announceForAccessibility(t)}};m.exports=c},23,[1,24,42,49]);
^~~~~~~
/app/android/app/build/generated/assets/react/release/index.android.bundle:38:3047: warning: the variable "DebuggerInternal" was not declared in function "value 16#"
__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),l=r(d[1]),u=r(d[2]),s=r(d[3]),n=r(d[4]),h=(r(d[5]),r(d[6])),o=r(d[7]),c=(r(d[8]),(function(){function c(){l(this,c),this._lazyCallableModules={},this._queue=[[],[],[],0],this._successCallbacks=new Map,this._failureCallbacks=new Map,this._callID=0,this._lastFlush=0,this._eventLoopStartTime=Date.now(),this._immediatesCallback=null,this.callFunctionReturnFlushedQueue=this.callFunctionReturnFlushedQueue.bind(this),this.callFunctionReturnResultAndFlushedQueue=this.callFunctionReturnResultAndFlushedQueue.bind(this),this.flushedQueue=this.flushedQueue.bind(this),this.invokeCallbackAndReturnFlushedQueue=this.invokeCallbackAndReturnFlushedQueue.bind(this)}return u(c,[{key:"callFunctionReturnFlushedQueue",value:function(t,l,u){var s=this;return this.__guard(function(){s.__callFunction(t,l,u)}),this.flushedQueue()}},{key:"callFunctionReturnResultAndFlushedQueue",value:function(t,l,u){var s,n=this;return this.__guard(function(){s=n.__callFunction(t,l,u)}),[s,this.flushedQueue()]}},{key:"invokeCallbackAndReturnFlushedQueue",value:function(t,l){var u=this;return this.__guard(function(){u.__invokeCallback(t,l)}),this.flushedQueue()}},{key:"flushedQueue",value:function(){var t=this;this.__guard(function(){t.__callImmediates()});var l=this._queue;return this._queue=[[],[],[],this._callID],l[0].length?l:null}},{key:"getEventLoopRunningTime",value:function(){return Date.now()-this._eventLoopStartTime}},{key:"registerCallableModule",value:function(t,l){this._lazyCallableModules[t]=function(){return l}}},{key:"registerLazyCallableModule",value:function(t,l){var u,s=l;this._lazyCallableModules[t]=function(){return s&&(u=s(),s=null),u}}},{key:"getCallableModule",value:function(t){var l=this._lazyCallableModules[t];return l?l():null}},{key:"callNativeSyncHook",value:function(t,l,u,s,n){this.processCallbacks(t,l,u,s,n);try{return g.nativeCallSyncHook(t,l,u)}catch(t){throw'object'==typeof t&&null!=t&&void 0===t.framesToPop&&/^Exception in HostFunction: /.test(t.message)&&(t.framesToPop=2),t}}},{key:"processCallbacks",value:function(t,l,u,s,n){(s||n)&&(s&&u.push(this._callID<<1),n&&u.push(this._callID<<1|1),this._successCallbacks.set(this._callID,n),this._failureCallbacks.set(this._callID,s)),this._callID++}},{key:"enqueueNativeCall",value:function(t,l,u,s,h){this.processCallbacks(t,l,u,s,h),this._queue[0].push(t),this._queue[1].push(l),this._queue[2].push(u);var o=Date.now();if(g.nativeFlushQueueImmediate&&o-this._lastFlush>=5){var c=this._queue;this._queue=[[],[],[],this._callID],this._lastFlush=o,g.nativeFlushQueueImmediate(c)}n.counterEvent('pending_js_to_native_queue',this._queue[0].length),this.__spy&&this.__spy({type:1,module:t+'',method:l,args:u})}},{key:"createDebugLookup",value:function(t,l,u){}},{key:"setImmediatesCallback",value:function(t){this._immediatesCallback=t}},{key:"__guard",value:function(t){if(this.__shouldPauseOnThrow())t();else try{t()}catch(t){s.reportFatalError(t)}}},{key:"__shouldPauseOnThrow",value:function(){return'undefined'!=typeof DebuggerInternal&&!0===DebuggerInternal.shouldPauseOnThrow}},{key:"__callImmediates",value:function(){n.beginEvent('JSTimers.callImmediates()'),null!=this._immediatesCallback&&this._immediatesCallback(),n.endEvent()}},{key:"__callFunction",value:function(t,l,u){this._lastFlush=Date.now(),this._eventLoopStartTime=this._lastFlush,this.__spy?n.beginEvent(t+"."+l+"("+o(u)+")"):n.beginEvent(t+"."+l+"(...)"),this.__spy&&this.__spy({type:0,module:t,method:l,args:u});var s=this.getCallableModule(t);h(!!s,'Module %s is not a registered callable module (calling %s)',t,l),h(!!s[l],'Method %s does not exist on module %s',l,t);var c=s[l].apply(s,u);return n.endEvent(),c}},{key:"__invokeCallback",value:function(l,u){this._lastFlush=Date.now(),this._eventLoopStartTime=this._lastFlush;var s=l>>>1,n=1&l?this._successCallbacks.get(s):this._failureCallbacks.get(s);n&&(this._successCallbacks.delete(s),this._failureCallbacks.delete(s),n.apply(void 0,t(u)))}}],[{key:"spy",value:function(t){c.prototype.__spy=!0===t?function(t){console.log((0===t.type?'N->JS':'JS->N')+" : "+(t.module?t.module+'.':'')+t.method+"("+JSON.stringify(t.args)+")")}:!1===t?null:t}}]),c})());m.exports=c},32,[33,7,8,37,38,39,19,40,20]);
And at the end of these warnings, this error appears:
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment.
Error: spawnSync ./gradlew ENOBUFS
at Object.spawnSync (internal/child_process.js:1041:20)
at spawnSync (child_process.js:609:24)
at execFileSync (child_process.js:636:15)
at runOnAllDevices (/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at buildAndRun (/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at /app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async Command.handleAction (/app/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:164:9)
Here are the relevant variant settings in app/build.gradle
:
def keystore = getPassword("local", "android_keystore_password")
def key = getPassword("local", "android_key_password")
...
signingConfigs {
release {
storeFile file('app.keystore')
storePassword keystore
keyAlias 'app'
keyPassword key
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
debug {
debuggable true
signingConfig signingConfigs.debug
}
stagingrelease {
initWith release
matchingFallbacks = ['release', 'debug']
}
productionrelease {
initWith release
matchingFallbacks = ['release']
}
}
React Native version:
System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
Memory: 1.03 GB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.6.0 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 19, 22, 23, 25, 26, 27, 28, 29
Build Tools: 22.0.1, 23.0.1, 25.0.2, 27.0.3, 28.0.3, 29.0.0, 29.0.0, 29.0.0, 29.0.1
System Images: android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
Android NDK: 20.0.5594570
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
npmPackages:
@react-native-community/cli: ^3.0.4 => 3.0.4
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
Steps to Reproduce:
npx react-native run-android --variant=release
with above context
Expected: App to successfully run with specified variant.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:19
- Comments:17 (1 by maintainers)
Top Results From Across the Web
0 - Stack Overflow
When I run it on my machine it works with no problem but when I run it on docker I get this error:...
Read more >Fixing React native gradlew access error - Baraa Bytes
Now react native is able to access android SDK tools allowing it to run your app. export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$ ...
Read more >Export apk react native - Metro OB GYN
apkFor windows, gradlew assembleRelease For Linux, ./gradlew assembleReleasenpx react-native run-android --variant=releaseBefore uploading the release.
Read more >gradlew assembleRelease vs react-native run-android - Reddit
Hi everyone, Started learning React Native 2 weeks ago and currently trying to finish wrapping up a little app that does little more...
Read more >Common React Native Errors - Medium
Solution 1: I was receiving this error message when running react-native run-android . When I ran cd android && ./gradlew clean ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We are also experiencing this issue.
Hermes Enabled RN 0.61.2
We are able to
gradlew bundleRelease
to build an apk/aab.Happy to provide any additional details.
same issue here, would rather not turn off hermes…