Android Studio正在为React-native项目生成非常旧的APK,例如3个月大

Android Studio正在为反应本机项目(如3个月大)生成非常旧的apk。但是在运行“ react-native run-android”命令时可以在模拟器中完美运行

过程- * 打开文件所在位置 * Build => Build Bundles => Build APK

尝试重新安装android studio,但仍然变老了apk

pingguwenjun 回答:Android Studio正在为React-native项目生成非常旧的APK,例如3个月大

在旧的本机版本中,当我们生成android APK时,有时捆绑包很旧,我们必须自己生成它。
在本机0.61中,我发现问题已解决。 在旧版本中,首先应将以下脚本添加到package.json

"scripts":{
...
"bundle-android": "react-native bundle --entry-file index.js  --platform android --dev false --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res",...
}

当您生成apk时,首先要在termail中运行以下脚本来生成新的包

npm run bundle-android

捆绑软件成功输出后,进入android目录并组装APK

cd android

./gradlew assembleRelease

,
react-native bundle --platform android --dev false --entry-file index.js -- 
bundle-output android/app/src/main/assets/index.android.bundle --assets-dest 
android/app/src/main/res/

如果您发现重复资源错误,而不是转到res文件夹并仅删除drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi,drawable-xxxhdpi文件夹,然后尝试重建项目。它将起作用。

,

这是因为,您有旧的index.android.bundle文件。请按照以下步骤更新此文件并创建一个新的APK:

  1. type Subscriber<T extends Events> { id: string; event: T; callback: EventHandlers<T>; } type OnProductAdded = 'OnProductAdded'; type OnProductDeleted = 'OnProductDeleted'; type Events = OnProductAdded | OnProductDeleted; type EventArgs = { OnProductAdded: { productName: string; id: string; }; OnProductDeleted: { id: string }; } type EventHandlers<T extends Events> = { [T in keyof EventArgs]: (args: T) => void; } function /*connection.*/on<T extends Events>(type: T,cb: EventHandlers<T>) { }
  2. react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
  3. curl "http://localhost:8081/index.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
本文链接:https://www.f2er.com/3162477.html

大家都在问