"package android.support.annotation does not exist" 在 androidX 迁移和 react-native 升级到 0.60.4 之后

"package android.support.annotation does not exist" after androidX migration and react-native upgrade to 0.60.4

我已经使用重构迁移到 androidX-> 从 Android Studio 迁移到 AndroidX。

而且我已经将我的 React Native 升级到 0.60.4

我在构建应用程序时遇到此错误。

error: package android.support.annotation does not exist
import android.support.annotation.Nullable;

我找到了这个解决方案,

它也有效!

但这些都是来自节点模块,我有太多这样的错误。

除了手动编辑之外,还有什么办法可以处理这些问题吗?

谢谢。

按照 https://github.com/mikehardy/jetifier/blob/master/README.md 中的说明使用 jetifier。

以下是自述文件的摘要:

1. First, use Android Studio's refactoring tool to convert your app re: the Android developer docs
2. npm install --save-dev jetifier
3. npx jetify
4. npx react-native run-android (your app should correctly compile and work)
5. Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again)