【问题标题】:React Native, react-native run-android close automatically after build successfullyReact Native, react-native run-android build 成功后自动关闭
【发布时间】:2020-10-23 14:50:13
【问题描述】:

我试图通过首先使用react-native start 启动服务器然后在我的设备中使用react-native run-android 运行我的反应本机应用程序,但是当它成功构建时它会自动关闭。 当我运行 react-native run-android

时会发生这种情况
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1752 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...

> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from C:\Users\DAWOR\Go-polo-master\node_modules\react-native\android

> Task :app:processDebugGoogleServices
Parsing json file: C:\Users\DAWOR\Go-polo-master\android\app\google-services.json

> Task :app:installDebug
07:10:22 V/ddms: execute: running am get-config
07:10:22 V/ddms: execute 'am get-config' on '4200336f97fc7483' : EOF hit. Read: -1
07:10:22 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'SM-G615F - 8.1.0' for app:debug
07:10:22 D/app-debug.apk: Uploading app-debug.apk onto device '4200336f97fc7483'
07:10:22 D/Device: Uploading file onto device '4200336f97fc7483'
07:10:22 D/ddms: Reading file permision of C:\Users\DAWOR\Go-polo-master\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------
07:10:24 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
07:10:48 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on '4200336f97fc7483' : EOF hit. Read: -1
07:10:48 V/ddms: execute: returning
07:10:48 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
07:10:48 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on '4200336f97fc7483' : EOF hit. Read: -1
07:10:48 V/ddms: execute: returning
Installed on 1 device.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 42s
318 actionable tasks: 3 executed, 315 up-to-date
info Connecting to the development server...
info Starting the app on "4200336f97fc7483"...
Starting: Intent { cmp=com.gopro/.MainActivity }
PS C:\Users\DAWOR\Go-polo-master> 

我试图清理缓存,但是当我运行 npm cache clean 和使用 npm cache clean --force 时它会抛出错误,它会显示 npm WARN using --force Recommended protections disabled. 任何人都可以告诉我发生了什么事

【问题讨论】:

    标签: android react-native android-studio gradle


    【解决方案1】:

    第 1 步(在 gradlew.properties 中添加这两行)

    android.useAndroidX=true
    android.enableJetifier=true
    

    第 2 步

    npm install
    npm install --save-dev jetifier 
    npx jetify  
    npx react-native run-android 
    

    第 3 步(调用)

    npx jetify
    

    更多细节在这里failed-to-run-jetifier-react-native

    【讨论】:

    • 第 1 步已经在 gradlew.properties 中定义,第 2 步 npm install 会抛出错误
    • 尝试“yarn”命令然后“npx jetify”和npx react-native run-android
    • yarn 总是抛出那个错误error Can't add "react-native-parsed-text": invalid package version undefined.
    • 并且 package.json 中没有 react-native-parsed-text
    猜你喜欢
    • 2017-05-12
    • 1970-01-01
    • 2019-12-23
    • 1970-01-01
    • 1970-01-01
    • 2018-04-19
    • 1970-01-01
    • 2020-09-08
    相关资源
    最近更新 更多