How to run existing react-native project with java-11 - react-native

I have create project using react-native init ProjectName. This project was created with java-8 version, but now I have changed my system and because of no more support for java-8 installed java-11 in system, So I have to use java-11 with my existing project.
When I run the code after starting npm using the command npm-start & react-native run-android, what issue I am getting is -
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '11.0.2'.
I have tried to change android configuration like gradle version and other but still no luck.
I also searched online but couldn't get satisfied answer, most of the answer is saying that uninstall java-11 and install java-8.
I also gone through the official website of react native still no luck.
https://github.com/facebook/react-native/issues/22487
OS - Ubuntu 18.0.4
Java vrsion install -11.0.2
react-native-cli: 2.0.1
react-native: 0.56.0
node - v10.15.3
npm - 6.4.1
"dependencies": {
"lodash": "^4.17.11",
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-elements": "^0.19.1",
"react-native-iphone-x-helper": "^1.2.0",
"react-native-navigation": "^2.3.0",
"react-native-segmented-control-tab": "^3.3.1",
"react-native-tabbar-bottom": "^1.0.4",
"react-native-vector-icons": "^6.1.0",
"react-redux": "^6.0.0",
"prop-types": "^15.6.2",
"redux": "^4.0.1"
},
classpath 'com.android.tools.build:gradle:3.3.1'
ext {
buildToolsVersion = "28"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
I just want to run my project in java 11 which is already working fine in java-8, because now unable to install Java -8 in my ubuntu system.

Related

How to update older version of nativescript project to work with version 8

i have a project i worked on some years back on my previous laptop(Samsung, Windows OS). I needed to refer back to that project recently so i move the source code to my current laptop (Mac M1). Upon running the app i got a bunch of errors. About 57 errors like this:
ERROR in ./node_modules/nativescript-screenshot/index.js 1:18-41
Module not found: Error: Can't resolve 'image-source' in '/Users/ad8kunle/Documents/nativescript-projects/skogapp/node_modules/nativescript-screenshot'
# ./app/profile/profile.js 10:13-47
# ./app/ sync .(xml%7Cjs%7Cs?css)$ ./profile/profile.js
# ./node_modules/#nativescript/webpack/dist/stubs/virtual-entry-javascript.js 3:16-89
ERROR in ./node_modules/nativescript-toast/toast.android.js 3:18-40
Module not found: Error: Can't resolve 'application' in '/Users/ad8kunle/Documents/nativescript-projects/skogapp/node_modules/nativescript-toast'
# ./app/home/home-page.js 10:12-41
# ./app/ sync .(xml%7Cjs%7Cs?css)$ ./home/home-page.js
# ./node_modules/#nativescript/webpack/dist/stubs/virtual-entry-javascript.js 3:16-89
ERROR in ./app/welcome/slides-view.js 2:47-80
Module not found: Error: Can't resolve 'ui/layouts/grid-layout' in '/Users/ad8kunle/Documents/nativescript-projects/skogapp/app/welcome'
# ./app/ sync .(xml%7Cjs%7Cs?css)$ ./welcome/slides-view.js
# ./node_modules/#nativescript/webpack/dist/stubs/virtual-entry-javascript.js 3:16-89
I ran tns --version on my previous laptop and its version 6.3. However, my current version is 8.3.2
My package.json looks like
"dependencies": {
"#nativescript/core": "~8.3.0",
"#nstudio/nativescript-cardview": "^2.0.0",
"#nstudio/nativescript-pulltorefresh": "^1.1.1",
"#progress-nativechat/nativescript-nativechat": "3.0.0",
"nativescript-accelerometer": "3.0.0",
"nativescript-background-http": "4.2.1",
"nativescript-blur": "^2.0.0",
"nativescript-camera": "4.5.0",
"nativescript-contacts": "^1.6.2",
"nativescript-exit": "^1.0.1",
"nativescript-fancyalert": "^3.0.9",
"nativescript-floatingactionbutton": "^5.1.0",
"nativescript-geolocation": "5.1.0",
"nativescript-image": "3.0.1",
"nativescript-image-cache-it": "^5.0.0-beta.20",
"nativescript-image-colors": "^1.1.0",
"nativescript-image-filters": "^2.2.2",
"nativescript-imagepicker": "7.1.0",
"nativescript-intl": "3.0.0",
"nativescript-iqkeyboardmanager": "1.5.1",
"nativescript-permissions": "^1.3.8",
"nativescript-phone": "^1.4.1",
"nativescript-plugin-firebase": "^10.5.2",
"nativescript-plugin-universal-links": "^1.0.1",
"nativescript-pulltorefresh": "^2.3.0",
"nativescript-ripple": "^2.2.1",
"nativescript-root-detection": "^1.0.0",
"nativescript-screenshot": "0.0.2",
"nativescript-social-share": "1.6.0",
"nativescript-sqlite": "^2.6.0",
"nativescript-status-bar": "^1.2.0",
"nativescript-theme-core": "~1.0.6",
"nativescript-toast": "^2.0.0",
"nativescript-ui-autocomplete": "6.0.1",
"nativescript-ui-calendar": "6.1.0",
"nativescript-ui-chart": "7.1.1",
"nativescript-ui-dataform": "6.0.0",
"nativescript-ui-gauge": "6.0.0",
"nativescript-ui-listview": "8.0.1",
"nativescript-ui-sidedrawer": "8.0.0",
"nativescript-urlhandler": "^1.3.0",
"nativescript-web-image-cache": "^5.0.0",
"nativescript-web-image-cache-with-fresco": "^2.0.2",
"nativescript-webrtc-plugin": "^2.0.0-alpha.22"
},
"devDependencies": {
"#nativescript/android": "8.3.0",
"#nativescript/webpack": "~5.0.0"
},
Already tried tns --migrate. That was whqt reduced the errors to 57. there were 215 before.
It's a HUGE jump to go from {N} v6 to v8, with lots of breaking changes. I bit the bullet and spent several months making the upgrade myself earlier this year. (To be fair, I was also making UI changes during the upgrade).
As a start, watch this video, probably at least twice: Migrating Legacy NativeScript 6 Project to 8
Good luck!

Compilation failed (android) after installation of react-native-keychain

This is a new installation on a RN 0.62.2 and Nodejs 12.18.0. After yarn add react-native-keychain, the app launch of npx react-native run-android failed with the error:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\D\code\js\xyz_app\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\DeviceAvailability.java:30: error: cannot find symbol
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE);
^
symbol: variable FEATURE_FACE
location: class PackageManager
C:\D\code\js\xyz_app\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\DeviceAvailability.java:34: error: cannot find symbol
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_IRIS);
^
symbol: variable FEATURE_IRIS
location: class PackageManager
2 errors
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-keychain:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Tried a few times with installation and the error is the same. The modules has been used in other app before and the error may be related to the recent update of the module. The OS is win10. react-native-keychain is 6.1.1. Here is the package.json:
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/native": "^5.5.1",
"#react-navigation/stack": "^5.5.1",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-device-info": "^5.6.1",
"react-native-elements": "^2.0.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-keychain": "^6.1.1",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.0.5",
"react-native-screens": "^2.8.0",
"react-native-vector-icons": "^6.6.0"
Bumped up the SDK version from 28 to 29 in build.gradle seems working. Here is the file after change:
buildToolsVersion = "29.0.3"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
A senior dev advised me to do this:
"I see, react-native-keychain is using lambdas which are available from java 8 upwards. We should tell it to use java 8 .
Add this block"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
in node_modules/react-native-keychain/android/build.gradle
add as shown below.

how to solve "null is not object(evaluating RNGestureHandlerModule.default.direction" in react native 5.0

I have installed all the dependencies according to the react navigation docs.. when I copied code from docs this error occurs..
my dependencies are
"dependencies": {
"#react-native-community/masked-view": "^0.1.6",
"#react-navigation/native": "^5.0.5",
"#react-navigation/stack": "^5.0.5",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-gesture-handler": "^1.6.0",
"react-native-paper": "^3.6.0",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.0.0-beta.7"
},
SOLUTION FOR ANDROID
From your project root folder run :
cd android
./gradlew clean
run project react-native run-android
SOLUTION FOR IOS
From your project root folder run :
cd ios
pod install
run project react-native run-ios
If these solutions didn't work remove your node_modules folder and re-install using npm install
NOTE :
Do not link packages using react-native link since you are using RN 0.60 >

What does 'npm:' means?

I've started working on a project in my new workplace .
It's react project and has a package.json which has the dependencies like the one below.
"dependencies": {
"babel-polyfill": "^6.26.0",
"gsap": "^2.0.2",
"lodash": "^4.17.11",
"mobx": "^5.1.2",
"mobx-react": "^5.4.2",
"react": "^16.5.2",
"react-dom": "npm:#hot-loader/react-dom",
"react-draggable": "^3.0.5",
"react-hot-loader": "^4.8.3",
"react-id-swiper": "^1.6.9",
"react-resize-detector": "^4.0.5"
},
For react-dom, the version is specified as "npm:#hot-loader/react-dom".
What does 'npm:' means?
My coworker guess it's the way that only yarn uses.
I wonder about this naming as 'npm install' doesn't install react-dom, but 'yarn install' install it.
Thank you for your help!
I think this dependency is installed wrong it should be:
react-dom#npm:#hot-loader/react-dom
It's a yarn name resolution, so #hot-loader/react-dom would be installed instead of react-dom#npm

React-Native Production APK crashes with a "babelHelpers.interopRequireDefault object is not a function" error

Been developing mobile apps using react-native for a good few months now but recently I've been coming across the following issue when creating release APK's...
ReactNativeJS: Object is not a function (evaluating '(0,babelHelpers.interopRequireDefault(u).default)()')
The only reference I've been able to find when debugging this issue is one from 2015 ("babelHelpers.interopRequireDefault is not a function" when upgrading to React Native 0.16.0-rc) but unfortunately it offers little assistance when figuring this issue out especially as it was targeted at react-native 0.16 and was promptly resolved.
This issue is only thrown when launching the release APK under Android (accessible via adb logcat) on either a device or emulator and there are no issues or error logs thrown when in dev mode.
In terms of the environment, I'm currently running the following:
yarn: 1.7.0
node: 10.4.0
react-native-cli: 2.0.1
react-native: 0.55.4
gradle: 2.14.1
package.json contains the following dependencies:
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-bgimage": "^1.4.0",
"react-native-navigation": "^1.1.463",
"react-native-root-toast": "^3.0.1",
"react-native-super-grid": "^2.3.2",
"react-native-vector-icons": "^4.6.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-jest": "^23.0.1",
"babel-preset-react-native": "4.0.0",
"eslint-config-react-native": "^2.0.0",
"jest": "^23.1.0",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
Build configuration includes both proguard and separate architecture builds enabled but I have tested the release APK's with both options set to false.
Not sure what else I can provide or where to look next, advise is much appreciated as this has been investigated for a while now :(
Let me know if any additional info is required.