【问题标题】:React Native App Stuck On Jetify in dev mode在开发模式下 React Native App Stuck On Jetify
【发布时间】:2019-08-20 22:22:12
【问题描述】:

我正在尝试在 0.60 上迁移我的应用程序,但它一直卡在 jetify 进程中。

基本上,在这一行之后:

info 运行 jetifier 将库迁移到 AndroidX。您可以使用“--no-jetifier”标志禁用它。

它只是卡住了,什么也不做。我需要 jetifier 用于 react-native-firebase 和其他一些本地库。有什么建议吗?

更新

看来问题出在符号链接上。我正在使用 Lerna。

【问题讨论】:

    标签: react-native android-jetifier


    【解决方案1】:

    还有一种情况是npx react-native run-android 卡在 jetifying 状态

    如果您运行 npm run android,它也会启动 metro 服务器,

    但是,要重新运行 npm run android,您需要关闭 Metro 命令窗口并允许 npm run android 启动新的 Metro 服务器

    【讨论】:

      【解决方案2】:

      最后我所做的是重写一个jetify,指定我需要jetify的模块。

      我的 jetify index.js:

      const {fork} = require('child_process');
      const {join} = require('path');
      const {getClassesMapping, readDir, chunk} = require('./src/utils');
      
      const cpus = require('os').cpus().length;
      
      const arg = process.argv.slice(2)[0];
      const mode = arg && (arg === 'reverse' || arg === '-r') ? 'reverse' : 'forward';
      const SEARCH_DIRS = [
        ........modules here
      ];
      
      const classesMapping = getClassesMapping();
      for (const SEARCH_DIR of SEARCH_DIRS) {
        const files = readDir(SEARCH_DIR);
      
        console.log(
          `Jetifier found ${
            files.length
          } file(s) to ${mode}-jetify. Using ${cpus} workers...`,
        );
      
        for (const filesChunk of chunk(files, cpus)) {
          const worker = fork(join(__dirname, 'src', 'worker.js'));
          worker.send({filesChunk, classesMapping, mode});
        }
      }
      

      还有 postinstall 在 package.json 中:

      "postinstall": "cp ./jetify.js ./node_modules/jetifier/index.js"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-14
        • 1970-01-01
        相关资源
        最近更新 更多