Android 4.4 Kit Kat上的React Native [错误:无法加载捆绑包]

时间:2018-10-15 08:52:47

标签: android react-native

我试图在Android 4.4(Kit Kat)设备上构建一个新的React Native项目。但是它未能加载Metro服务器启动的捆绑包,但捆绑没有启动,并且在其他帖子中提出了一些建议后,我尝试设置IP并使用开发菜单手动托管,但仍然存在错误。有关如何解决此问题的任何建议。

设备名称:Zebra TC / 70设备

反应本机版本:0.55.3

Error Screen

ip & host set manually

Yes the Metro Bundler is started

[已解决]:解决我的唯一办法是将设备升级到Lollipop,因为adb无法在Android版本<5.0中完成,并且没有其他解决方案,例如通过dev设置手动设置ip和host有效< / strong>

1 个答案:

答案 0 :(得分:0)

我在 Github issue 上找到了这个解决方案,它对我有用:

(确保 rn 服务器正在运行 npm start,从 android/app/build/outputs/apk 中删除 app-debug.apk,如果之前安装过从 android 卸载并从根文件夹运行以下命令)

  1. 创建目录 use Twilio\Jwt\AccessToken; use Twilio\Jwt\Grants\VideoGrant; class AccessTokenController extends Controller { public function generate_token() { // Substitute your Twilio Account SID and API Key details $accountSid = env('TWILIO_ACCOUNT_SID'); $apiKeySid = env('TWILIO_API_KEY_SID'); $apiKeySecret = env('TWILIO_API_KEY_SECRET'); $identity = uniqid(); // Create an Access Token $token = new AccessToken( $accountSid, $apiKeySid, $apiKeySecret, 3600, $identity ); // Grant access to Video $grant = new VideoGrant(); $grant->setRoom('cool room'); $token->addGrant($grant); // Serialize the token as a JWT echo $token->toJWT(); } }

  2. 创建文件 mkdir android/app/src/main/assets,它是 index.android.js index.js

    的克隆
  3. cp index.js index.android.js

  4. react-native link

  5. curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"