I am having a hard time trying to configure my emulator with react native. I already have the emulator installed but can't properly run the statement: react-native run-android this is the error I keep getting. (p.s. there seems to be no solutions in the troubleshoot. I have tried to change the gradle-properties which was ineffective)
C:\Users\Dell\AwesomeProject>react-native run-android
Scanning folders for symlinks in C:\Users\Dell\AwesomeProject\node_modules (31ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '10'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
I had the same issue. After upgrading to Ubuntu Bionic which comes with Java 10 which is not supported by react-native.
I'm using the following script now:
#!/bin/bash
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/
export PATH=$JAVA_HOME/bin:$PATH
react-native run-android
I change the env path to Java 8 and run the app.
You can try upgrading your gradle or downgrading java ... I would prefer upgrading your gradle.
Upgrading our Gradle
1 .Modify android/build.gradle :
Add google() inside repositories
buildscript {
repositories {
jcenter()
// add google() here
google()
Update com.android.tools.build.gradle to 3.1.0
buildscript {
repositories {
jcenter()
google()
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.2.3'
// update from 2.2.3 to 3.1.0
classpath 'com.android.tools.build:gradle:3.1.0'
Add google() inside repositories after dependencies :
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
allprojects {
repositories {
mavenLocal()
jcenter()
// add googgle() here
google()
Add android.enableAapt2=false to android/gradle.properties
android.enableAapt2=false // < --- add here
android.useDeprecatedNdk=true
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
Update gradle version in android/gradle/wrapper/gradle-wrapper.properties :
// from version 2.14.1
distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
// change to 4.4
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
Runreact-native run-android. (This might take a while since it’ll be downloading the updated gradle version.)
Related
The build error looks something like this:
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'My Project'.
Could not determine the dependencies of null.
Could not resolve all task dependencies for configuration ':classpath'.
Could not resolve com.facebook.react:react-native:+.
Required by:
project :
No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.
The consumer was configured to find a runtime of a library compatible with Java 11,
packaged as a jar, and its dependencies declared externally, as well
as attribute 'org.gradle.plugin.api-version' with value '7.3.3'
update this below content in project level build.gradle:
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// ...
}
}
it's working for me
FIX INSIDE
Steps to resolve the react-native issue that we are facing since couple of days.
Goto package.json and upgrade the react-native version to 0.64.4.(or whatever the supported version we have on the GitHub thread)
Run yarn install.
Now cd android
./gradlew clean
cd ..
yarn android (now your project will execute properly)
Note: This issue occurred because of the new release of the react native(4th nov), here I'm attaching the link for the reference.
URL : https://github.com/facebook/react-native/issues/35210
(if you face any issues do let me know i'll help you in resolving the same.)
This fix works:
Reason for Failures : The build failures for Android was due to the publish of the React Native version 0.71.0-rc0 to Maven and because of which when the gradle is syncing its picking this 0.71.0-rc0 version of react-native rather then your current version of react-native.
Made it work without upgrading react-native version and by adding this in build.gradle, this works (hermes enabled or not, along with flipper too)
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
final snippet looks like this
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
gradle clean and rebuild after this fix. Then you can react native run android successfully.
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
If you dont want to put this fix, you can update your react native version for the project to the react native patch version as mentioned here
https://github.com/facebook/react-native/issues/35210
I'm using create-react-app. When I run npm start (react-scripts start) it continuously builds the changes for me and does it magic. But what is the output folder for that? I know when I build it manually where the files go.
I want to use firebase emulator to serve the current version (the continuous build) of my react all but I don't understand where's the output folder or how to achieve it.
You could try this package https://github.com/Nargonath/cra-build-watch
Install it and add the script to your package.json
{
"scripts": {
"watch": "cra-build-watch"
}
}
and run it
npm run watch
more info here
https://ibraheem.ca/writings/cra-write-to-disk-in-dev/
and if you go to the react repo issue linked in the article you would find more workarounds
tl;dr
run npm run build, not npm run start
More Detail
react-scripts start runs webpack-dev-server internally. As a default setting, webpack-dev-server serves bundled files from memory and does not write files in directory.
If you want to write files with webpack-dev-sever, you could set writeToDisk option to true in your dev server configuration.
However, I dont think this is what you want to serve on firebase emulator. Webpack-dev-server does not build optimal app for production, and you also need to use react-app-rewired to customize dev server configuration in cra template.
What you want to do is npm run build to run react-scripts build, which builds optimized production app in /build directory.
How can transform my react project into script to connect it to html page?
I am a new one in react please be tolerant. My boss demands to get completed script to connect it to html page without node and etc. What shall I do? Thank you.
Please check this url:
https://blog.bitsrc.io/react-production-deployment-part-3-heroku-316319744885
Also, Please check these steps:
In package.json, added this line to the scripts
"heroku-postbuild":
"NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run
build --prefix client".
Then added this
"engines": { "node" : "[your node version]" } after scripts.
In index.js, put the following code after your routes set up
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
const path = require("path");
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build",
"index.html"));
});
}
I assume that you use git for version control and already install Heroku.
Open your terminal, then Heroku login -> Heroku create -> git push Heroku
master. If you do not get any error, you are a success to deploy your app.
Hope you will get it to work.
In order to get rid of node, you need to first build your project. If you've initialized your project with create-react-app, run this command:
npm run build
A folder named 'build' will appear in your project root containing your production app. Now the build folder is ready to build and you can serve it with a static server like 'serve'. To install 'serve' via npm, do this:
npm install -g serve
that's it! you can serve it now:
serve -s build
You can find out more about deployment here:
https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment
by using create-react-app
https://create-react-app.dev/docs/getting-started
https://create-react-app.dev/docs/deployment
dev: npm start or yarn start.
prod: npm run build or yarn build.
My project is going from standalone to Web, Our new WebSite is getting created in AngularJS so Protractor is the tool selected for Test Automation.
I want to Integrate Typescript with dependencies of Jasmine and Node so that I don't get errors such as
cannot find name Describe
cannot find name it
cannot find name Expect
Can Anyone tell me how to add Jasmine and Protractor dependencies, so that when I hit ctrl + space i'll get all options available.
I have installed Typescript. And I am getting protractor dependencies such as browser, element, by etc.
What should i do for describe,it,expect (Jasmine stuffs) ?
I use Visual Studio Code everyday to write my scripts, it's my current favourite editor for Protractor because of its built in support for TypeScript!
Here are the following things which can come into my mind which could help you setup your framework-
Download the latest VS Code version - https://code.visualstudio.com/download
Install typescript globally npm install -g typescript
Install protractor globally npm install -g protractor
Create your project folder
Setup you project folder for git, node and typescript -
npm init -f // will create default package.json stating its nodejs project
git init // will create .git file, you project is now git project
tsc --init // will create tsconfig.json stating its typescript project
Install typings and dev dependencies-
npm install --save-dev protractor // this will install protractor as a dev dependency
npm install --save-dev typescript // this will install typescript as a dev dependency
npm install --save-dev #types/jasmine // jasmine typings
npm install --save-dev #types/node // node typings
At this point you have setup your basic protractor-typescript project and you can see all the typings and dependencies in package.json. Now you are good to write your typed scripts :).
Now compile your scripts by running -
tsc or tsc -w
After successfull compilation all your javascript files would be generated.
The run protractor
protractor config.js
You can also setup your vs code for debugging with protractor which I have mentioned here - Protractor -VS Code Debugging
For more details pls refer the TypeScript Tutorial, Protractor API
The Typescript error you are observing this is due to VS Code not recognizing global typescript 2.0 version.
To solve this open vscode go to preferences--> user settings --> settings.json will be opened and enter the highlighted path as shown
Save your file and restart VSCode now you are good to go :)
I agree with the answers given. Just want to share a hack with you.
You don't need to transpile your Typescript codes to JavaScript anymore.
Create a launch.js file
require('ts-node').register({
compilerOptions: {
module: 'commonjs'
},
disableWarnings: true,
fast: true
});
exports.config = require('./config/protractor.conf.ts').config;
And kick start protractor execution like:
> protractor launch
You can save yourself from the headache of transpiling every time you make a change to typescript files.
Happy testng!
I created a script in gradle. When I select Run -> External Tools -> External Tools Configurations -> Gradle build for Creating new build and its throwing error An error has occurred.
"See error log for more details.!java.lang.NullPointerException " its displayed in messagebox
After editing build.gradle file same error also displaying! "An internal error occurred during: "Calculating Gradle Tasks...".java.lang.NullPointerException"
apply plugin: 'java'
apply plugin: 'eclipse'
version = "1.0"
sourceCompatibility = 1.7
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version':
version
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.+'
}
}
repositories {
mavenCentral()
}
sourceSets {
unitTest {
java.srcDir file('src/test/java')
resources.srcDir file('src/test/resources')
}
}
task wrapper(type: Wrapper) {
description = 'Install Gradle wrapper'
gradleVersion = '1.10'
}
dependencies {
compile 'org.apache.poi:poi:3.9'
compile 'org.testng:testng:6.8.5'
compile 'org.seleniumhq.selenium:selenium-server:2.39.0'
compile 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.42.2'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'net.sf.json-lib:json-lib:2.4:jdk15'
compile 'log4j:log4j:1.2.17'
}
test {
useTestNG(){
options.suites("src/test/resources/testng.xml")
}
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
Anything i missed in configuration, anyone can help me?
I have created a Gradle project in Eclipse, and pasted your build.gradle contents into mine.
Your gradle script seems fine to me. I could:
- See Gradle tasks for the project in Gradle Tasks view
- Open Gradle
Build launcher configuration wizard via context menu on the project
explorer and via the Run External Tools
- Could launch Gradle tasks
All that with STS 3.6.0 M1 (latest Gradle Eclipse integration
Which STS are you using? Or which version of Gradle Eclipse integration?
What's the stack trace for the NPE?
Try upgrading your Gradle eclipse integration from this update site: http://dist.springsource.com/release/TOOLS/gradle If that still won't work try the latest, STS 3.6.0 RC1 update site and pick Gradle Eclipse Integration from there http://dist.springsource.com/milestone/TOOLS/update/3.6.0.RC1/e4.4 (replace e4.4 with your eclipse version, e.g. e4.3, e4.2, e3.8, e3.7)