Skip to content

Commit 08953fa

Browse files
committed
Add endianness to signature size in DEX signing task
Explicitly sets ByteOrder.BIG_ENDIAN for the 4-byte signature size when appending to the DEX file, ensuring consistent format. Also adds an adb push command to upload the signed DEX to the target device.
1 parent 8adfcfd commit 08953fa

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

plugin/build.gradle.kts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import java.nio.ByteBuffer
2+
import java.nio.ByteOrder
23
import java.nio.file.Files
34
import java.security.KeyStore
45
import java.security.PrivateKey
@@ -255,12 +256,22 @@ tasks.register("sign-dex") {
255256

256257

257258
// Append format: [DEX][SIG][SIG_SIZE(4 bytes little-endian)]
258-
val sigSizeBytes = ByteBuffer.allocate(4).putInt(sigBytes.size).array()
259+
val sigSizeBytes = ByteBuffer.allocate(4)
260+
.order(ByteOrder.BIG_ENDIAN) // or LITTLE_ENDIAN, but keep consistent
261+
.putInt(sigBytes.size)
262+
.array()
263+
259264
val output = dexBytes + sigBytes + sigSizeBytes
260265

261266
Files.write(dexOutputSigned.toPath(), output)
262267

263268
println("Signed DEX written to: ${dexOutputSigned.absolutePath}")
269+
270+
adb(
271+
"push",
272+
dexOutputSigned.absolutePath,
273+
"/data/adb/modules/$targetModule/webroot/plugins/$pluginName.signed.dex"
274+
)
264275
}
265276
}
266277

0 commit comments

Comments
 (0)