【问题标题】:Stuck at Whitescreen after building Ionic React android app构建 Ionic React android 应用程序后卡在白屏
【发布时间】:2020-06-02 17:12:49
【问题描述】:

ionic run android -l --external 有了这个,我必须在手机上通过热重载测试应用程序,但是当我尝试在工作室构建它时,它只是在电容器徽标后显示一个空白屏幕。

我只是在测试 ionic,只是让标签模板继续测试它。

这是我构建 apk 的方法。 ionic run android -> 然后在 android studio -> 构建 apk

【问题讨论】:

    标签: android reactjs android-studio ionic-framework


    【解决方案1】:

    我遇到了类似的问题,使用 WSL 和 Windows Android Studio:

    在 WSL 上:

    ionic start photo-gallery tabs --type=react --capacitor 
    cd photo-gallery/ 
    ionic integrations enable capacitor
    npx cap init photo-app com.mike.atkinson 
    
    mkdir www
    -- create a www/index.html file
    npx cap add android 
    ionic serve                  #check everything runs OK in a browser then ^C
    #line below stops a warning in the Windows Android Studio when the App is run.
    mkdir node_modules/@capacitor/android/capacitor/build/intermediates/check_manifest_result/debug/checkDebugManifest/out
    

    在 Windows 上:

        Run Android Studio
        Select photo-app 
        build it
        Create an Android Virtual Machine - using Pixel XL with Android 10
        Select it
        Run photo-app                                                <-- just a blank screen
        Connect phone (Umidigi A3S  running Android 10)
        Select phone 
        Run photo-app                     <-- just shows the splash screen then a blank screen
    

    由于我是 Android 新手,这可能是我做错了什么,但由于这是一个示例 React 应用程序,我不知道是什么。

    原来我犯了两个简单的错误:

    1. 在电容器.config.json 中,webDir 应设置为“build”

    2. Ionic serve 只为 web 服务构建,为你需要做的 android 目标构建:

    npm run build
    

    然后在 Windows 端运行 Android Studio。

    【讨论】:

    • 是的,对我来说也是 webDir 的问题,应该是“构建”我记得在第一次运行时将其更改为公共,因为它不会让我运行它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 1970-01-01
    • 1970-01-01
    • 2018-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多