npx react-native run-android error after updating react native - react-native

I have upgraded my react native and created a new project.
When i run npx react-native run-android iam getting the below error.
D:\React Native Playground\AwesomeProject\node_modules\react-native\cli.js{ "root": "D:\React Native Playground\AwesomeProject", "reactNativePath": "D:\React Native Playground\AwesomeProject\node_modules\react-native", "dependencies": {}, "commands": [ { "name": "log-ios", "description": "starts iOS device syslog tail" }, { "name": "run-ios", "description": "builds your app and starts it on iOS simulator", "examples": [ { "desc": "Run on a different simulator, e.g. iPhone 5", "cmd": "react-native run-ios --simulator \"iPhone 5\"" }, { "desc": "Pass a non-standard location of iOS directory", "cmd": "react-native run-ios --project-path \"./app/ios\"" }, { "desc": "Run on a connected device, e.g. Max's iPhone", "cmd": "react-native run-ios --device \"Max's iPhone\"" }, { "desc": "Run on the AppleTV simulator", "cmd": "react-native run-ios --simulator \"Apple TV\" --scheme \"helloworld-tvOS\"" } ], "options": [ { "name": "--simulator [string]", "description": "Explicitly set simulator to use. Optionally include iOS version betweenparenthesis at the end to match an exact version: \"iPhone 6 (10.0)\"", "default": "iPhone 11" }, { "name": "--configuration [string]", "description": "Explicitly set the scheme configuration to use", "default": "Debug" }, { "name": "--scheme [string]", "description": "Explicitly set Xcode scheme to use" }, { "name": "--project-path [string]", "description": "Path relative to project root where the Xcode project (.xcodeproj) lives.", "default": "ios" }, { "name": "--device [string]", "description": "Explicitly set device to use by name. The value is not required if you have a single device connected." }, { "name": "--udid [string]", "description": "Explicitly set device to use by udid" }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--verbose", "description": "Do not use xcpretty even if installed" }, { "name": "--port [number]", "default": 8081 }, { "name": "--terminal [string]", "description": "Launches the Metro Bundler in a new window using the specified terminal path." } ] }, { "name": "log-android", "description": "starts logkitty" }, { "name": "run-android", "description": "builds your app and starts it on a connected Android emulator or device", "options": [ { "name": "--root [string]", "description": "Override the root directory for the android build (which contains the android directory)", "default": "" }, { "name": "--variant [string]", "description": "Specify your app's build variant", "default": "debug" }, { "name": "--appFolder [string]", "description": "Specify a different application folder name for the android source. If not, we assume is \"app\"", "default": "app" }, { "name": "--appId [string]", "description": "Specify an applicationId to launch after build.", "default": "" }, { "name": "--appIdSuffix [string]", "description": "Specify an applicationIdSuffix to launch after build.", "default": "" }, { "name": "--main-activity [string]", "description": "Name of the activity to start", "default": "MainActivity" }, { "name": "--deviceId [string]", "description": "builds your app and starts it on a specific device/simulator with the given device id (listed by running \"adb devices\" on the command line)." }, { "name": "--no-packager", "description": "Do not launch packager while building" }, { "name": "--port [number]", "default": 8081 }, { "name": "--terminal [string]", "description": "Launches the Metro Bundler in a new window using the specified terminal path." }, { "name": "--tasks [list]", "description": "Run custom Gradle tasks. By default it's \"installDebug\"" }, { "name": "--no-jetifier", "description": "Do not run \"jetifier\" – the AndroidX transition tool. By default it runs before Gradle to ease working with libraries that don't support AndroidX yet. See more at: https://www.npmjs.com/package/jetifier.", "default": false } ] } ], "assets": [], "platforms": { "ios": {}, "android": {} }, "haste": { "providesModuleNodeModules": [ "react-native" ], "platforms": [ "ios", "android" ] }, "project": { "ios": { "sourceDir": "D:\React Native Playground\AwesomeProject\ios", "folder": "D:\React Native Playground\AwesomeProject", "pbxprojPath": "D:\React Native Playground\AwesomeProject\ios\AwesomeProject.xcodeproj\project.pbxproj", "podfile": "D:\React Native Playground\AwesomeProject\ios\Podfile", "podspecPath": null, "projectPath": "D:\React Native Playground\AwesomeProject\ios\AwesomeProject.xcodeproj", "projectName": "AwesomeProject.xcodeproj", "libraryFolder": "Libraries", "sharedLibraries": [], "plist": [], "scriptPhases": [] }, "android": { "sourceDir": "D:\React Native Playground\AwesomeProject\android\app", "isFlat": false, "folder": "D:\React Native Playground\AwesomeProject", "stringsPath": "D:\React Native Playground\AwesomeProject\android\app\src\main\res\values\strings.xml", "manifestPath": "D:\React Native Playground\AwesomeProject\android\app\src\main\AndroidManifest.xml", "buildGradlePath": "D:\React Native Playground\AwesomeProject\android\app\build.gradle", "settingsGradlePath": "D:\React Native Playground\AwesomeProject\android\settings.gradle", "assetsPath": "D:\React Native Playground\AwesomeProject\android\app\src\main\assets", "mainFilePath": "D:\React Native Playground\AwesomeProject\android\app\src\main\java\com\awesomeproject\MainApplication.java", "packageName": "com.awesomeproject" } }}
^
FAILURE: Build failed with an exception.
Where:
Script 'D:\React Native Playground\AwesomeProject\node_modules#react-native-community\cli-platform-android\native_modules.gradle' line: 200
What went wrong:
A problem occurred evaluating script.
Failed to parse React Native CLI configuration. Expected running 'npx.cmd --quiet --no-install react-native config' command from 'D:\React Native Playground\AwesomeProject' directory to output valid JSON, but it didn't. This may be caused by npx resolving to a legacy global react-native binary. Please make sure to uninstall any global 'react-native' binaries: 'npm uninstall -g react-native react-native-cli' and try again.
My package.json
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.5"
},
"devDependencies": {
"#babel/core": "7.8.4",
"#babel/runtime": "7.8.4",
"#react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"eslint": "6.8.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.56.4",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}

Per the error message, it sounds like npx may be resolving to a legacy react-native binary. If you have previously installed react-native-cli, this is likely the culprit, as the cli is now included along with the react-native binary. Per react-native docs:
If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues.
If you haven't already, try uninstalling react-native and react-native-cli with npm and then using npx (comes with node) for future react-native usage.
npm uninstall -g react-native react-native-cli
Then,
npx react-native init AwesomeProject

Related

Apk file which made using eas build of react native expo cli is not works on real device

I've made an app using React Native Expo Cli. It works fine on Expo Go App and I've generated apk file using eas build --profile development --platform android and eas build --platform android. But these does not work on real device.
I've used eas build for making apk because earlier I was using expo build:android but now If I write this command on cmd and hit enter then after some seconds it is showing "Unsupported SDK version: our app builders do not support SDK version 45, yet. The latest SDK version is 45.0.0. Unsupported SDK version". You can check my app.json and eas.json file.
app.json
{
"expo": {
"name": "RoyalVivahVendor",
"slug": "RoyalVivahVendor",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.royalvivah.royalvivahvendor",
"versionCode": 1
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
eas.json
{
"cli": {
"version": ">= 0.52.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {
"android": {
"buildType": "apk"
}
}
},
"submit": {
"production": {}
}
}

configure google admob for expo

I am trying to integrate googles Admob service into my expo initialized react native app via the expo-ads-admob package. the package works successfully in the expo-go development environment, however when I build the app and via eas build --profile development --platform ios and install it onto my phone, it immediately closes as soon as I open it. I have already removed all imports of the Admob components within the app so it seems like just installing the package itself causes the app to crash at runtime. Since the app builds successfully, there are no error messages I can use to start debugging, any help would be greatly appreciated. This is the configuration in my app.json if that's relevant
{
"expo": {
"name": "MyApp",
"slug": "MyApp",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#FFF"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"config": {
"googleMobileAdsAppId": "ca-app-pub-TESTID"
},
"bundleIdentifier": "com.package.identifier"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFF"
},
"config": {
"googleMobileAdsAppId": "ca-app-pub-TESTID"
},
"package": "com.package.identifier"
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
expo-ads-admob is deprecated, so when using EAS Build the app breaks.
Expo itself recommends using react-native-google-mobile-ads, or try uninstalling EAS with npm uninstall -g eas-cli and using expo build.

React-Native android Apk built using expo doesn't run

I'm new to react native and I'm trying to build an android app. The app works fine with no errors when I run the development server on my pc and then scan the QR code to open my app in the Expo app. I ran expo build:android and when it finished I downloaded and installed the apk on my phone, but it doesn't open. The app stays stuck on the expo splash screen. I've tried installing and running the apk on Nox player (android emulator) but it produced the same results. Below is my app.json file.
{
"sdkVersion": "39.0.2",
"name": "confusion",
"displayName": "confusion",
"expo": {
"name": "confusion",
"icon": "./components/images/icon.png",
"slug": "confusion",
"version": "1.0.0",
"ios": {
"bundleIdentifier": "net.food.confusion.confusion",
"buildNumber": "1.0.0"
},
"android": {
"package": "net.food.confusion.confusion",
"versionCode": 1
},
"assetBundlePatterns": [
"**/*"
],
"splash": {
"image": "./components/images/splash.png"
}
}
}

How to remove publish code update in expo?

I configured the module as a stand-alone app to use it. So when I'm building the Android APK, I'm running the "expo publicish," and I'm making the APK in the Android studio.
By the way, I found that if I changed the Expo source , it would be automatically updated.
How do I prevent this kind of automatic update?
expo-cli version: expo-cli 2.18.5
"expo": "^30.0.0",
my App.json
{
"expo": {
"name": "test",
"description": "This project is really great.",
"slug": "test",
"privacy": "public",
"sdkVersion": "30.0.0",
"packagerOpts": {
"config": "./rn-cli.config.js"
},
"platforms": ["android"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"android": {
"package": "com.jackson.myapp",
"publishBundlePath": "android/app/src/main/assets/shell-app.bundle",
"publishManifestPath": "android/app/src/main/assets/shell-app-manifest.json",
"splash": {
"backgroundColor": "#000000"
}
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"usesIcloudStorage": true,
"bundleIdentifier": "com.jackson.myapps",
"publishBundlePath": "ios/mvw/Supporting/shell-app.bundle",
"publishManifestPath": "ios/mvw/Supporting/shell-app-manifest.json"
},
"isDetached": true,
"detach": {
"iosExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/ios-v2.8.4-sdk30.0.0-3de13133-1adc-4ba1-85691e570b4.tar.gz",
"androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v2.8.1-sdk30.0.0-0fde103b-be3d-43f9-bc48-30336971.tar.gz"
},
"scheme": "exp6c94a01048724a76bc92dca0c"
}
}
For Android, you will need to change the default settings.
you take a look at the ExpoKit note under this section
you guessing that for
AppConstants.java
, you need to set this line:
public static boolean ARE_REMOTE_UPDATES_ENABLED = false;
you have to run expo publish at least once before you make the APK.

How to publish React-Native component to NPM?

What are the steps to follow publish React-native component to npm?
Am trying to publish sample component in NPM.
Do we need to build that before?
if yes, how?
Please can any one tell in detail along with the commands?
No you no need to build, just put android native code in android and ios directory and a index.js in root to refreance them, then
Add readme
give proper versioning
give proper name
Like this in package.json
{
"_from": "package-name#0.1.3",
"_id": "package-name#0.1.3",
"_inBundle": false,
"_location": "/package-name",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "package-name#0.1.3",
"name": "package-name",
"escapedName": "package-name",
"rawSpec": "0.1.3",
"saveSpec": null,
"fetchSpec": "0.1.3"
},
"_requiredBy": [
"/"
],
"_spec": "0.1.3",
"author": {
"name": "Your name",
"email": "your#gmail.com"
},
"bugs": {
"url": "https://github.com/bug/issues"
},
"dependencies": {
"prop-types": "^15.6.0"
},
"description": "description about pacakge",
"homepage": "https://github.com/#readme",
"keywords": [
"react-native",
"react",
"dnd"
],
"license": "MIT",
"main": "index.js",
"name": "package-name",
"peerDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/package-name.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "0.1.3"
}