react-native: [Resolved] Release build fails with Hermes and RN 0.61.4 on mac

React Native version: 0.61.4

Steps To Reproduce

here and here https://github.com/facebook/react-native/issues/25601#issuecomment-510856047

  1. In proguard-rules.pro -keep class com.facebook.hermes.unicode.** { *; }

  2. In build.gradle classpath 'com.android.tools.build:gradle:3.4.2'

  3. In gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip

  4. My updated react.gradle

  5. Copied node_modules/react-native/react.gradle to android/app/react.gradle

  6. updated app/build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,
    hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes",
]

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);

apply from: "./react.gradle"

dependencies {
.
.
.
   if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }

}
  1. npm install with package.json --only=dev

"hermes-engine": "^0.1.1",

  1. run ./android/gradlew clean and react-native run-android --variant=release

Error Trace

Here is the error trace

Describe what you expected to happen:

Release build should successfully go through and the app should not crash.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 17 (1 by maintainers)

Most upvoted comments

I am facing same issue.

See screenshot attached. I am facing it in release build only. In both versions i.e. react-native 0.61.3 and 0.61.4.

Screenshot 2019-11-05 at 5 00 11 PM Screenshot 2019-11-05 at 4 59 31 PM

sorry for a big file but there is a lot more but I skip it. @holospeed I’m using react native 61.5 version

_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},7,[1,8,31,43]); ^~~~~~~ /Users/admin/Projects/lnchoba/android/app/build/generated/assets/react/release/index.android.bundle:25:3047: warning: the variable "DebuggerInternal" was not declared in function "value 14#" __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},19,[20,24,25,26,27,28,3,29,4]); ^~~~~~~~~~~~~~~~ /Users/admin/Projects/lnchoba/android/app/build/generated/assets/react/release/index.android.bundle:89:57098: warning: the variable "setTimeout" was not declared in function "Pi" __d(function(e,t,n,r,i,l,a){"use strict";var o=t(a[0]);t(a[1]);var u=t(a[2]),c=t(a[3]),s=t(a[4]);function f(e){return e.name="Invariant Violation",e}var d=null,p={};function h(){if(d)for(var e in p){var t=p[e],n=d.indexOf(e);if(!(-1<n))throw f(Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `"+e+"`."));if(!g[n]){if(!t.extractEvents)throw f(Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `"+e+"` does not."));for(var r in g[n]=t,n=t.eventTypes){var i=void 0,l=n[r],a=t,o=r;if(v.hasOwnProperty(o))throw f(Error("EventPluginHub: More than one plugin attempted to publish the same event name, `"+o+"`."));v[o]=l;var u=l.phasedRegistrationNames;if(u){for(i in u)u.hasOwnProperty(i)&&m(u[i],a);i=!0}else l.registrationName?(m(l.registrationName,a),i=!0):i=!1;if(!i)throw f(Error("EventPluginRegistry: Failed to publish event `"+r+"` for plugin `"+e+"`."))}}}}function m(e,t){if(y[e])throw f(Error("EventPluginHub: More than one plugin attempted to publish the same registration name, `"+e+"`."));y[e]=t}var g=[],v={},y={};function b(e,t,n,r,i,l,a,o,u){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(e){this.onError(e)}}var T=!1,E=null,x=!1,w=null,S={onError:function(e){T=!0,E=e}};function k(e,t,n,r,i,l,a,o,u){T=!1,E=null,b.apply(S,arguments)}function C(e,t,n,r,i,l,a,o,u){if(k.apply(this,arguments),T){if(!T)throw f(Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."));var c=E;T=!1,E=null,x||(x=!0,w=c)}}var _=null,P=null,R=null;function N(e,t,n){var r=e.type||"unknown-event";e.currentTarget=R(n),C(r,t,void 0,e),e.currentTarget=null}function I(e){var t=e._dispatchListeners,n=e._dispatchInstances;if(Array.isArray(t))throw f(Error("executeDirectDispatch(...): Invalid `event`."));return e.currentTarget=t?R(n):null,t=t?t(e):null,e.currentTarget=null,e._dispatchListeners=null,e._dispatchInstances=null,t}function U(e,t){if(null==t)throw f(Error("accumulateInto(...): Accumulated items must not be null or undefined."));return null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function z(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}var M=null;function A(e){if(e){var t=e._dispatchListeners,n=e._dispatchInstances;if(Array.isArray(t))for(var r=0;r<t.length&&!e.isPropagationStopped();r++)N(e,t[r],n[r]);else t&&N(e,t,n);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}var D=function(e){if(d)throw f(Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."));d=Array.prototype.slice.call(e),h()},F=function(e){var t,n=!1;for(t in e)if(e.hasOwnProperty(t)){var r=e[t];if(!p.hasOwnProperty(t)||p[t]!==r){if(p[t])throw f(Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `"+t+"`."));p[t]=r,n=!0}}n&&h()};function O(e,t){var n=e.stateNode;if(!n)return null;var r=_(n);if(!r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw f(Error("Expected `"+t+"` listener to be a function, instead got a value of `"+typeof n+"` type."));return n}function j(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function W(e,t,n){for(var r=[];e;)r.push(e),e=j(e);for(e=r.length;0<e--;)t(r[e],"captured",n);for(e=0;e<r.length;e++)t(r[e],"bubbled",n)}function H(e,t,n){(t=O(e,n.dispatchConfig.phasedRegistrationNames[t]))&&(n._dispatchListeners=U(n._dispatchListeners,t),n._dispatchInstances=U(n._dispatchInstances,e))}function Q(e){e&&e.dispatchConfig.phasedRegistrationNames&&W(e._targetInst,H,e)}function B(e){if(e&&e.dispatchConfig.phasedRegistrationNames){var t=e._targetInst;W(t=t?j(t):null,H,e)}}function V(e){if(e&&e.dispatchConfig.registrationName){var t=e._targetInst;if(t&&e&&e.dispatchConfig.registrationName){var n=O(t,e.dispatchConfig.registrationName);n&&(e._dispatchListeners=U(e._dispatchListeners,n),e._dispatchInstances=U(e._dispatchInstances,t))}}}function L(){return!0}function Y(){return!1}function X(e,t,n,r){for(var i in this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=n,e=this.constructor.Interface)e.hasOwnProperty(i)&&((t=e[i])?this[i]=t(n):"target"===i?this.target=r:this[i]=n[i]);return this.isDefaultPrevented=(null!=n.defaultPrevented?n.defaultPrevented:!1===n.returnValue)?L:Y,this.isPropagationStopped=Y,this}function q(e,t,n,r){if(this.eventPool.length){var i=this.eventPool.pop();return this.call(i,e,t,n,r),i}return new this(e,t,n,r)}function $(e){if(!(e instanceof this))throw f(Error("Trying to release an event instance into a pool of a different type."));e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function G(e){e.eventPool=[],e.getPooled=q,e.release=$}o(X.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=L)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=L)},persist:function(){this.isPersistent=L},isPersistent:Y,destructor:function(){var e,t=this.constructor.Interface;for(e in t)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefau

i am facing the same issue too 😕

System: OS: macOS 10.15.1 CPU: (4) x64 Intel® Core™ i5-7600K CPU @ 3.80GHz Memory: 25.63 MB / 8.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.13.0 - /usr/local/bin/node Yarn: 1.19.1 - /usr/local/bin/yarn npm: 6.12.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 19, 21, 22, 23, 24, 25, 26, 27, 28, 29 Build Tools: 28.0.3, 29.0.2 System Images: android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-24 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.5 AI-191.8026.42.35.5977832 Xcode: 11.2/11B52 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.4 => 0.61.4 npmGlobalPackages: react-native-cli: 2.0.1

java version “1.8.0_231” Java™ SE Runtime Environment (build 1.8.0_231-b11) Java HotSpot™ 64-Bit Server VM (build 25.231-b11, mixed mode)

Képernyőfotó 2019-11-12 - 9

if you don’t have duplication, than:

  • in terminal go to your android folder in the project (cd android)
  • run: ./gradlew clean
  • go back to the project directory (cd …)
  • if you have not added jetifier to your project add it (for example: yarn add jetifier)
  • run: npx jetify in the project directory
  • go to android folder (cd android)
  • run: ./gradlew bundleRelease

build bundleRelease success but fail to install, and still react-native run-android --variant=release… fails

Property duplication caused my issue! There was a property multiple times in my code! After the fix it has been built successfully!

THANK YOU @yusufsal !!!