使用AndroidX和React Native的问题 [英] Issues using AndroidX and React Native

查看:196
本文介绍了使用AndroidX和React Native的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图将AndroidX集成到我的混合React Native项目中,并且遇到了Jetifier不在本地"项目上运行的问题.这导致我的所有React Native库仍然使用旧的支持库.我已经在gradle.properties文件中放入了适当的行:

I've been trying to integrate AndroidX into my hybrid React Native project, and I've run into the issue that Jetifier doesn't run on "local" projects. This results in all of my React Native libraries still using the old support libraries. I've put the appropriate lines into my gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

这适用于任何远程库,但是React Native将其所有库作为本地模块放置在磁盘上.

This works for any remote libraries, but React Native places all of it's libraries as local modules on disk.

我已经尝试了很多事情,但是到目前为止,我最好的解决方案是安装软件包后脚本,该脚本基本上是手动替换所有软件包,并将库添加/删除到各种gradle脚本中.

I've tried a lot of things, but so far my best solution is a post package-install script that basically manually replaces all of the packages and add/removes libraries to the various gradle scripts.

这是一个非常手工的过程,并非超级可持续.有没有更好的方法来解决此问题?

This is a very manual process and not super sustainable. Is there a better way to handle this issue?

推荐答案

在安装后脚本中尝试使用下面的npm Jetifier软件包

try using the npm Jetifier package below in a postinstall script

https://www.npmjs.com/package/jetifier

自述文件:

Make sure your app is AndroidX
npm install --save-dev jetifier
npx jetify (may take a while)
npx react-native run-android

这篇关于使用AndroidX和React Native的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆