Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/platform-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"dependencies": {
"@react-native-community/cli-config-android": "^16.0.2",
"@rnef/tools": "^0.6.2",
"adm-zip": "^0.5.16",
"tslib": "^2.3.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
spawn,
spinner,
} from '@rnef/tools';
import AdmZip from 'adm-zip';
import { findAndroidBuildTool, getAndroidBuildToolsPath } from '../../paths.js';
import { buildJsBundle } from './bundle.js';

Expand Down Expand Up @@ -65,14 +64,12 @@ export async function signAndroid(options: SignAndroidOptions) {

loader.start('Initializing output APK...');
try {
const zip = new AdmZip(options.apkPath);
// Remove old signature files
zip.deleteFile('META-INF/*');
zip.writeZip(tempApkPath);
fs.mkdirSync(tempPath, { recursive: true });
fs.copyFileSync(options.apkPath, tempApkPath);
} catch (error) {
throw new RnefError(
`Failed to initialize output APK file: ${options.outputPath}`,
{ cause: (error as SubprocessError).stderr }
{ cause: error }
);
}
loader.stop(`Initialized output APK.`);
Expand Down Expand Up @@ -141,11 +138,24 @@ async function replaceJsBundle({
apkPath,
jsBundlePath,
}: ReplaceJsBundleOptions) {
const tempPath = path.dirname(apkPath);
try {
const zip = new AdmZip(apkPath);
zip.deleteFile('assets/index.android.bundle');
zip.addLocalFile(jsBundlePath, 'assets', 'index.android.bundle');
zip.writeZip(apkPath);
fs.mkdirSync(path.join(tempPath, 'assets'), { recursive: true });

const tempBundlePath = path.join(
tempPath,
'assets',
'index.android.bundle'
);
fs.copyFileSync(jsBundlePath, tempBundlePath);

// Delete the existing bundle
await spawn('zip', ['-d', apkPath, 'assets/index.android.bundle']);

// Add the new bundle with the correct path structure
await spawn('zip', ['-r', apkPath, 'assets'], {
cwd: tempPath,
});
} catch (error) {
throw new RnefError(
`Failed to replace JS bundle in destination file: ${apkPath}}`,
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading