任务:react-native-screens:React Navigation 中的 javaPreCompileDebug 错误 5.x
Task :react-native-screens:javaPreCompileDebug error in React Navigation 5.x
我使用以下命令创建了一个 React-Native 项目:
react-native init samplerouting
然后我通过以下步骤启用了导航(based on its documentation):
1-
npm install @react-navigation/native
2-
npm install
react-native-reanimated
react-native-gesture-handler
react-native-screens
react-native-safe-area-context
@react-native-community/masked-view
3-将以下两行添加到 android/app/build.gradle
中的 dependencies
部分
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
4-我修改了MainActivity.java
如下
package com.samplerouting;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "samplerouting";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
5-然后在我的入口文件的顶部添加以下内容(index.js)
import 'react-native-gesture-handler';
完成,我想 运行 我的项目只在 android 设备上,这就是为什么我拒绝以下步骤:
cd ios
pod install
cd ..
现在,当我 运行 我的项目
react-native start
react-native run-android
我收到以下错误
Task :react-native-screens:javaPreCompileDebug FAILED
此版本中使用了已弃用的 Gradle 功能,使其成为
与 Gradle 6.0 不兼容。使用'--warning-mode all'来显示
个别弃用警告。
注意:我尝试了以下命令但它不起作用
cd android && gradlew clean
我的package.json:
{
"name": "samplerouting",
"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-native-community/masked-view": "^0.1.6",
"@react-navigation/native": "^5.0.0",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-gesture-handler": "^1.5.6",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.2",
"react-native-screens": "^2.0.0-beta.2"
},
"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"
}
}
此错误与 Gradle
有关。
这就是我更新 SDK
的原因,所以它运行良好。
不用说了:
在Environment-variable
中我们要添加以下3个变量:
1- ANDROID_HOME :(你的SDK路径) J:\ReactNative\AndroidSDK\Android\Sdk
2- JAVA_HOME :(你的 JDK 路径) C:\Program Files\Java\jdk1.8.0_231
3- platform-tools :(你的 PLATFORM-TOOLS 路径) J:\ReactNative\AndroidSDK\Android\Sdk\platform-tools
注意: 上面的路径是我电脑上的,自行提供路径
我使用以下命令创建了一个 React-Native 项目:
react-native init samplerouting
然后我通过以下步骤启用了导航(based on its documentation):
1-
npm install @react-navigation/native
2-
npm install
react-native-reanimated
react-native-gesture-handler
react-native-screens
react-native-safe-area-context
@react-native-community/masked-view
3-将以下两行添加到 android/app/build.gradle
dependencies
部分
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
4-我修改了MainActivity.java
如下
package com.samplerouting;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "samplerouting";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
5-然后在我的入口文件的顶部添加以下内容(index.js)
import 'react-native-gesture-handler';
完成,我想 运行 我的项目只在 android 设备上,这就是为什么我拒绝以下步骤:
cd ios
pod install
cd ..
现在,当我 运行 我的项目
react-native start
react-native run-android
我收到以下错误
Task :react-native-screens:javaPreCompileDebug FAILED
此版本中使用了已弃用的 Gradle 功能,使其成为 与 Gradle 6.0 不兼容。使用'--warning-mode all'来显示 个别弃用警告。
注意:我尝试了以下命令但它不起作用
cd android && gradlew clean
我的package.json:
{
"name": "samplerouting",
"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-native-community/masked-view": "^0.1.6",
"@react-navigation/native": "^5.0.0",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-gesture-handler": "^1.5.6",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.2",
"react-native-screens": "^2.0.0-beta.2"
},
"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"
}
}
此错误与 Gradle
有关。
这就是我更新 SDK
的原因,所以它运行良好。
不用说了:
在Environment-variable
中我们要添加以下3个变量:
1- ANDROID_HOME :(你的SDK路径) J:\ReactNative\AndroidSDK\Android\Sdk
2- JAVA_HOME :(你的 JDK 路径) C:\Program Files\Java\jdk1.8.0_231
3- platform-tools :(你的 PLATFORM-TOOLS 路径) J:\ReactNative\AndroidSDK\Android\Sdk\platform-tools
注意: 上面的路径是我电脑上的,自行提供路径