我在我的React-Native项目中遇到了一个问题,该问题早先工作得很好,但突然间它停止了工作.每当我使用命令时:
react-native run-android
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
找不到Android项目.也许首先运行react-native android?
我试过跑:
react-native android
Run Code Online (Sandbox Code Playgroud)
但它说:
Unrecognized command 'android' Run react-native --help to see list of all available commands
尝试后:
D:\ProjectRoot\ReactNativeProjects\AwesomeProject>react-native eject
Run Code Online (Sandbox Code Playgroud)
返回的错误是:
在D:\ ProjectRoot\ReactNativeProjects\AwesomeProject \node_modules(48ms)中扫描符号链接的文件夹
name必须在app.json配置文件中定义应用程序才能定义项目名称.它不得包含任何空格或破折号.
这是app.json文件:
{
"expo": {
"name": "AwesomeProject",
"description": "A very interesting project.",
"slug": "AwesomeProject",
"privacy": "public",
"sdkVersion": "30.0.0",
"platforms": ["ios", "android"],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.project.first"
},
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain", …Run Code Online (Sandbox Code Playgroud) 我在Windows 7(64位)计算机上的DOS控制台中运行以下命令.
npm install -g yarn
yarn add global react-native
yarn add global react-native-cli
react-native init sample
Run Code Online (Sandbox Code Playgroud)
运行后react-native init sample,控制台已关闭.
错误日志显示:
D:\Mobile>"$basedir/../../Users/pramaswamy/AppData/Local/Yarn/.global/node_modules/.bin/react-native.cmd" "$@"
D:\Mobile>exit $?
Run Code Online (Sandbox Code Playgroud) 我正在尝试安装expo-cli.
当我使用时npm install -g expo-cli,它会安装以下输出。
当我尝试运行该expo命令时,出现系统找不到指定路径的错误。然后我卸载了npm uninstall -g expo-cli
我卸载node并npm清理了我的系统,然后我尝试expo-cli使用yarn global add expo-cli. 它安装了以下输出。
在此之后,expo init命令起作用了。但是当我expo start在项目文件夹中运行时,我得到以下输出。
我不知道还能做什么。我在 Windows 10 上。
我将在我的应用程序中使用react-native-push-notification进行通知,但是当我使用此库时,它给我这样的错误.....
> Task :react-native-push-notification:compileDebugJavaWithJavac FAILED
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:7: error: cannot find symbol
import android.app.NotificationChannel;
^
symbol: class NotificationChannel
location: package android.app
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:480: error: cannot find symbol
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
^
symbol: variable O
location: class VERSION_CODES
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:488: error: cannot find symbol
int importance = NotificationManager.IMPORTANCE_DEFAULT;
^
symbol: variable IMPORTANCE_DEFAULT
location: class NotificationManager
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:489: error: cannot find symbol
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
^
symbol: class NotificationChannel
location: class RNPushNotificationHelper
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:489: error: cannot find symbol
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, …Run Code Online (Sandbox Code Playgroud)