安卓端搭建环境以及启动记录
按照提示安装java等环境 第一次启动报错如果:

尝试安装gradle
brew install gradle
再次执行
react-native run-android
报错信息如下:
▶ react-native run-android
info JS server already running.
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
> Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot /Users/wanpan/work/rn/demo/node_modules/react-native/android
> Task :react-native-webview:compileDebugJavaWithJavac FAILED
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java:14: 错误: 找不到符号
import androidx.annotation.RequiresApi;
^
符号: 类 RequiresApi
位置: 程序包 androidx.annotation
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java:15: 错误: 程序包androidx.core.content不存在
import androidx.core.content.ContextCompat;
^
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java:16: 错误: 程序包androidx.core.content不存在
import androidx.core.content.FileProvider;
^
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java:3: 错误: 程序包androidx.core.content不存在
import androidx.core.content.FileProvider;
^
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java:10: 错误: 找不到符号
public class RNCWebViewFileProvider extends FileProvider {
^
符号: 类 FileProvider
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java:15: 错误: 找不到符号
import androidx.annotation.RequiresApi;
^
符号: 类 RequiresApi
位置: 程序包 androidx.annotation
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java:16: 错误: 程序包androidx.core.content不存在
import androidx.core.content.ContextCompat;
^
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java:178: 错误: 找不到符号
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
^
符号: 类 RequiresApi
位置: 类 RNCWebViewModule
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java:742: 错误: 找不到符号
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
^
符号: 类 RequiresApi
位置: 类 RNCWebChromeClient
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java:224: 错误: 找不到符号
if (ContextCompat.checkSelfPermission(getCurrentActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
^
符号: 变量 ContextCompat
位置: 类 RNCWebViewModule
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java:352: 错误: 找不到符号
return FileProvider.getUriForFile(getReactApplicationContext(), packageName + ".fileprovider", capturedFile);
^
符号: 变量 FileProvider
位置: 类 RNCWebViewModule
/Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java:787: 错误: 找不到符号
if (ContextCompat.checkSelfPermission(mReactContext, permissions.get(i)) != PackageManager.PERMISSION_GRANTED) {
^
符号: 变量 ContextCompat
位置: 类 RNCWebChromeClient
注: /Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: /Users/wanpan/work/rn/demo/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
12 个错误
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-webview:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
27 actionable tasks: 1 executed, 26 up-to-date
error 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
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.
找到的办法是说react-native-webview版本问题
it's weird, try to remove it first with react-native uninstall react-native-webview,
then install it again with react-native install react-native-webview@5.8.1
maybe your local still caching the last installed
github issue 地址 解决办法:
▶ react-native uninstall react-native-webview
▶ react-native install react-native-webview@5.8.1
安卓常见启动报错
Error: Unable to resolve module `./index` from`/Users/wanpan/work/rn/demo/node_modules/react-native/.`:
The module `./index` could not be found from `/Users/wanpan/work/rn/demo/node_modules/react-native/.`.
Indeed, none of these files exist:
解决办法:
react-native start -- --reset-cache
启动报错

chmod 755 android/gradlew