在开发人员模式下将Native App卡在Jetify上

时间:2019-08-20 22:22:12

标签: react-native android-jetifier

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

基本上,在此行之后:

  

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

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

更新

似乎问题出在符号链接中。我正在使用Lerna。

2 个答案:

答案 0 :(得分:0)

最后,我所做的是重写了一个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});
  }
}

和package.json中的postinstall

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

答案 1 :(得分:0)

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

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

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