Build failed after upgrade react native to 0.44 v - android

I just upgraded react native to 0.44.0 version and I get this error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-navigation:compileReleaseJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
And Android Studio's Event log :
Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :react-native-navigation:generateDebugSources, :react-native-navigation:generateDebugAndroidTestSources, :react-native-navigation:mockableAndroidJar, :react-native-navigation:prepareDebugUnitTestDependencies, :realm:generateDebugSources, :realm:generateDebugAndroidTestSources, :realm:mockableAndroidJar, :realm:prepareDebugUnitTestDependencies]
Need some help with that ! Thanks !
Environment
React Native Navigation version: 1.1.65
React Native version: 0.44.0
Platform(s) (iOS, Android, or both?): Android
Device info (Simulator/Device? OS version? Debug/Release?): AVD from Android Studio (6.0 API 23) and tested with a second AVD (7.1.1 API 25) => got same build failed
EDIT 1 :
Here my pacakage.json
{
"name": "App",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "^15.5.4",
"react-native": "^0.44.0",
"react-native-checkbox": "^1.1.0",
"react-native-navigation": "^1.1.65",
"realm": "^1.2.0",
"redux": "^3.6.0"
},
"devDependencies": {
"babel-jest": "19.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "19.0.2",
"react-test-renderer": "~15.4.1"
},
"jest": {
"preset": "react-native"
}
}
EDIT 2 :
I finally updated my build.gradle app to 25 compileSdkVersion from 23 and the buildToolsVersion to '25.0.2' from '23.x.x'.
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
It compiled and I can run my app again for now.

Using automatic installation solved my pb

Related

React native(android) assembleRelease gets bundle assembling error

{
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"start": "node node_modules/react-native/local-cli/cli.js start",
"load-script": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"test": "jest"
},
"dependencies": {
"#react-native-community/async-storage": "1.7.1",
"axios": "^0.18.0",
"native-base": "^2.12.1",
"prop-types": "^15.7.2",
"react": "16.8.3",
"react-native": "0.59.5",
"react-native-extended-stylesheet": "^0.11.1",
"react-native-gesture-handler": "1.4.0",
"react-native-image-slider": "^2.0.3",
"react-native-linear-gradient": "^2.5.6",
"react-native-snap-carousel": "^3.8.4",
"react-navigation": "^3.11.1",
"react-redux": "^7.1.3",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"#babel/core": "7.4.4",
"#babel/runtime": "7.4.4",
"babel-jest": "24.7.1",
"eslint-config-rallycoding": "^3.2.0",
"jest": "24.7.1",
"jetifier": "^1.6.5",
"metro-react-native-babel-preset": "0.54.0",
"react-test-renderer": "16.8.3",
"redux-devtools": "^3.5.0",
"remote-redux-devtools": "^0.5.0"
},
"jest": {
"preset": "react-native"
}
}
//build.gradle android
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
}
i ran .\gradlew assembleRelease and it crashed after that i ran the same command with --info and this is what it's showing me
i've tried upgrading and down grading and removing some of unused libs but nothing changed.
> Task :app:bundleReleaseJsAndAssets
Caching disabled for task ':app:bundleReleaseJsAndAssets' because:
Build cache is disabled
Task ':app:bundleReleaseJsAndAssets' is not up-to-date because:
Task has failed previously.
Starting process 'command 'cmd''. Working directory: C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app Command: cmd /c node node_modules/react-native/cli.js bundle --platform android --dev false --reset-cache --entry-file index.android.js --bundle-output C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\android\app\build\generated\assets\react\release\index.android.bundle --assets-dest C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\android\app\build\generated\res\react\release
Successfully started process 'command 'cmd''
warning: the transform cache was reset.
error The resource `C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\index.android.js` was not found.. Run CLI with --verbose flag for more details.
> Task :app:bundleReleaseJsAndAssets FAILED
:app:bundleReleaseJsAndAssets (Thread[Execution worker for ':' Thread 6,5,main]) completed. Took 3.955 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
i also get uses or overrides a deprecated API and Deprecated Gradle features were used, making it incompatible with Gradle 6.0 for react-native-gesture-handler in android studio. i get
Try this once , ./gradlew assembleRelease -x bundleReleaseJsAndAssets please check once.
UPDATE:
gradlew assembleRelease will only build/bundle your application for production. You need to sign the APK file yourself.
These are the steps which I take when I want to run my application in production mode:
1.keytool -genkey -v -keystore key.keystore -alias app-alias -keyalg RSA -keysize 2048 -validity 10000
2.cd android && gradlew assembleRelease && cd ..
3.jarsigner -verbose -keystore \path_to_key\key.keystore \path_to_apk\app-release-unsigned.apk app-alias
4.zipalign -f -v 4 \path_to_apk\app-release-unsigned.apk appName.apk
Follow these steps and your app should be installed successfully.
Do revert in case of any concerns.
Please use the same compileSdkVersion, buildToolsVersion and support library projects as in the main application project.

Apps keeps stopping after linking realm to react native

Anyone facing the problem on the latest realm (2.25.0) with react native (0.59.0)?
There's no problem with when I link the realm to react-native. However, when I ran the 'react-native run-android' on a real device (currently I'm testing on two devices, Oneplus 5 - Android Pie & Oppo F1s - Android Lollipop), the bundling successful, but the apps never get started. I unlinked the realm from react-native, it returns me 'Missing Realm Constructor...' (which is in my expectation).
It does works on emulator without any problem, it only runs into a problem on real devices.
Below is my package.json
{
"name": "testing",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.0",
"realm": "^2.25.0"
},
"devDependencies": {
"#babel/core": "^7.3.4",
"#babel/runtime": "^7.3.4",
"babel-jest": "^24.5.0",
"jest": "^24.5.0",
"metro-react-native-babel-preset": "^0.53.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
Steps to reproduce:
react-native init testing
npm install --save realm
react-native link realm
react-native run-android
Does anyone have an idea on this issue?
Appreciate for your help.
try this:
go to build.gradle then
android {
...
defaultConfig {
...
and add this
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
to default config. it must look like this :
defaultConfig {
...
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
}

React-Native - react-native-update-gradle - Error

i had an error with my React-Native Project for Android.
My first error was the following:
I added the "react-native-location" Library. After i run the Command "react-native link", the error "compileOnly" was thrown.
So my first try was, upadate NPM and Node.JS.
But it wasn´t the right solution for my Problem.
After that, i had google the Error and i want to update grandle with "react-native-update-gradle". My main Problem now is, when i run the "react-native link" command, i get the following error:
C:\Computer\Apps\Projects\XXX>react-native link
Scanning folders for symlinks in C:\Computer\Apps\Projects\XXX\node_modules (70ms)
rnpm-install info Platform 'ios' module react-native-orientation is already linked
rnpm-install info Platform 'android' module react-native-orientation is already linked
internal/validators.js:125
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:125:11)
at Object.join (path.js:427:7)
at getSDKPath (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:13:12)
at getPTPath (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:17:20)
at Object.activateADB (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:5:42)
at Object.<anonymous> (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\cli.js:101:6)
at Module._compile (internal/modules/cjs/loader.js:734:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
at Module.load (internal/modules/cjs/loader.js:626:32)
at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
C:\Computer\Apps\Projects\XXX\node_modules\react-native\local-cli\core\makeCommand.js:27
throw new Error(`Error occurred during executing "${command}" command`);
^
Error: Error occurred during executing "node ./node_modules/react-native-update-gradle/cli.js" command
at ChildProcess.prelink (C:/Computer/Apps/Projects/XXX/node_modules/react-native/local-cli/core/makeCommand.js:27:15)
at ChildProcess.emit (events.js:197:13)
at maybeClose (internal/child_process.js:978:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
I tried to fix the Error, but the error is still there.
I had the following Environments
Window 10
React-Native 0.55.4
React-Native-Cli 2.0.1
NodeJS v11.9.0
npm 4.6.0
android/build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com'
}
}
}
ext {
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "28.0.3"
supportLibVersion = "28.1.1"
playServicesVersion = "15.0.1"
}
package.json
{
"name": "XXX",
"version": "1.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"run-android": "react-native run-android"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-image-slider": "^2.0.3",
"react-native-image-zoom-viewer": "^2.2.25",
"react-native-orientation": "^3.1.3",
"react-native-pinch-zoom-view": "^0.1.6",
"react-native-responsive-image": "^2.3.1",
"react-native-router-flux": "^4.0.0-beta.28",
"react-native-scrolltotop": "0.0.6",
"react-native-slideshow": "^1.0.1",
"react-native-swipe-gestures": "^1.0.2",
"react-native-update-gradle": "^1.1.0",
"react-native-vector-icons": "^4.6.0",
"react-native-zoom-view": "^1.0.2"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
If you need more information to help me, please tell me that.
Thanks for your help.
Best Regards
Hi Sebastian ! After you run the command react-native link, you have to run the command react-native run-android or react-native run-ios. So that the library you have installed adjusts to your react native settings. This is work for me, after I installed the library or package. hope this helps.

React native android stuck in :app:mergeDebugResources

When i run react-native run-android android building stuck in :app:mergeDebugResources and does not report any error.
Here is my package.json file :
{
"name": "listeo",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.48.2"
},
"devDependencies": {
"babel-jest": "21.0.2",
"babel-preset-react-native": "3.0.2",
"jest": "21.0.2",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
Android build tools version is : 23.0.1
I tested it with android build tools 25 and 26 but didn't fixed.
How can i solve this problem?
try to remove the node_modules folder, then run npm install, also dont forget to check and update the required components on your SDK Manager, after that you can react-native run-android
try with run cd android && ./gradlew clean && cd.. && react-native run-android
also keep build tool as it's default also be patient some times takes time

How to enable stacktrace react-native run-android command?

I'm running a react native project via the react-native run-android. But during the build it fails stating that :react-native-device-info:processReleaseResources FAILED. Which doesn't give much info, so I tried running with react-native run-android --stacktrace as suggested but that isn't a recognized command.
How can you enable stacktrace / verbose logging with react-native run-android command?
This is the detail of the error which is too short to figure out at build:
:react-native-device-info:processReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-device-info:processReleaseResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Brian\AppData\Local\Android\sdk\build-tools\23.0.1\aapt.exe'' 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.
BUILD FAILED
Total time: -12.542 secs
Package.json for reference:
{
"name": "StarterKit",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"jest": {
"preset": "react-native",
"setupFiles": [
"<rootDir>/jest.setup.js"
],
"transformIgnorePatterns": [
"node_modules/(?!react-native|tcomb-form-native|apsl-react-native-button,react-native-device-info|react-clone-referenced-element)"
],
"collectCoverage": true,
"verbose": true
},
"dependencies": {
"html-entities": "^1.2.0",
"jwt-decode": "^2.1.0",
"qs": "^6.3.0",
"react": "15.4.2",
"react-addons-shallow-compare": "^15.4.2",
"react-native": "^0.40.0",
"react-native-device-info": "^0.9.6",
"react-native-elements": "^0.9.2",
"react-native-google-analytics-bridge": "git+https://github.com/mcnamee/react-native-google-analytics-bridge.git",
"react-native-router-flux": "^3.37.0",
"react-native-side-menu": "^0.20.1",
"react-native-tab-view": "0.0.48",
"react-native-vector-icons": "^4.0.0",
"react-redux": "^5.0.1",
"redux": "^3.6.0",
"redux-logger": "^2.7.0",
"redux-thunk": "^2.1.0",
"striptags": "^2.1.1",
"tcomb-form-native": "^0.6.1"
},
"devDependencies": {
"babel-core": "^6.17.0",
"babel-eslint": "^7.1.0",
"babel-jest": "18.0.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react-native": "1.9.1",
"babel-register": "^6.16.3",
"eslint": "^3.9.1",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.4.1",
"invariant": "^2.2.2",
"jest": "18.1.0",
"jest-react-native": "^18.0.0",
"react-test-renderer": "15.4.2"
}
}
build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
#EricHua23's answer is basically correct, except that instead of running ./gradlew assembleDebug --stacktrace, you should run ./gradlew.bat installDebug --stacktrace, as this is the command that's actually run by react-native run-android. (and some of the errors you'd want to get the stack-trace for only occur in the installing/late-build portion, rather than the assembly portion)
Also, make sure you run it in the android folder. (so run cd android in the console before running the gradlew command)
Try to build react-native-device-info separately with ./gradlew assembleDebug and make sure react-native-device-info is all right. I have the same problems because of my network which is blocked and can not reach jcenter.
By the way, --stacktrace should be add as gradle parameters, I doubt react-native does not pass it to gradle.
If running on Windows run following command in your project's root directory:
1. cd android
2. gradlew.bat installDebug --stacktrace
I use package.json file like this, for shortcut to shell commands, in my ViroMedia Sample App:
{
"name": "ViroSample",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"android": "react-native run-android --variant arrelease",
"and_bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"ios": "react-native run-ios",
"gradle_build": "cd android && ./gradlew --stacktrace --info assembleRelease -x bundleArReleaseJsAndAssets",
"gradle_install": "cd android && ./gradlew installArDebug --stacktrace --info",
"test": "jest"
},
"dependencies": {
"axios": "^0.19.0",
"expo": "^35.0.0",
"react": "16.8.3",
"react-native": "^0.61.5",
"react-viro": "2.15.0"
},
"devDependencies": {
"#babel/core": "^7.5.5",
"#babel/runtime": "^7.5.5",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
I issue the following command from my project root directory (iMac bash shell):
yarn gradle_install
Please see the script block above for other shell commands.
Note: in windows this is gradlew.bat.
Happy Coding :-)
From mac this will work
1. cd android
2. ./gradlew installDebug --stacktrace
Give a try to react-native start
This shows errors verbosely.

Categories

Resources