MacOS系統 React-Native項目0.59版本從開發到提交審覈記錄(二)

安卓端搭建環境以及啓動記錄

按照提示安裝java等環境 第一次啓動報錯若是:html

根據提示執行了clean命令,發現沒有安裝gradle

嘗試安裝gradlejava

brew install gradle
複製代碼

再次執行node

react-native run-android
複製代碼

報錯信息以下:react

▶ 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 地址 解決辦法:android

▶ 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:
複製代碼

解決辦法:git

react-native start -- --reset-cache
複製代碼

啓動報錯

執行命令:

chmod 755 android/gradlew
複製代碼
相關文章
相關標籤/搜索