You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.2 KiB
94 lines
3.2 KiB
SET KEYSTORE_NAME[0]=baiye.keystore
|
|
SET KEYSTORE_ALIAS[0]=baiye
|
|
SET KEYSTORE_STOREPASS[0]=matchsrpg1234
|
|
SET KEYSTORE_KEYPASS[0]=matchsrpg1234
|
|
|
|
SET KEYSTORE_NAME[1]=baiyeint.keystore
|
|
SET KEYSTORE_ALIAS[1]=baiyeint
|
|
SET KEYSTORE_STOREPASS[1]=matchsrpg1234
|
|
SET KEYSTORE_KEYPASS[1]=matchsrpg1234
|
|
|
|
REM 需要重签名的apk名字
|
|
SET SOURCE_APK=srpg_0.8.0_2021-02-26_20_24_18_p4_1611408_framw_test.apk
|
|
REM 默认配置,默认是v1v2v3一起签名
|
|
SET "mOption="
|
|
REM v1v2v3签名配置,通过修改true为false来决定是否打开对应的签名,v4暂不可用
|
|
SET "mOption=--v3-signing-enabled true --v2-signing-enabled true"
|
|
|
|
REM 需要android sdk的支持
|
|
set SDK_URL=C:\Users\Administrator\AppData\Local\Android\sdk
|
|
REM 检测android的支持
|
|
if not defined apksigner (
|
|
for /d %%i in (%SDK_URL%\build-tools\??.?.?) do (
|
|
if %%i GEQ %SDK_URL%\build-tools\24.0.3 (
|
|
set apksigner=%%i\apksigner.bat
|
|
set zipalign=%%i\zipalign
|
|
)
|
|
)
|
|
echo 请确认您的Android SDK目录下有版本大于等于24.0.3的build-tools
|
|
)
|
|
REM 工作文件夹
|
|
SET CURRENT_PATH=%~dp0
|
|
echo %CURRENT_PATH%
|
|
REM 临时文件夹
|
|
SET TEMP_PATH=%CURRENT_PATH%\temp
|
|
REM 临时apk
|
|
SET TEMP_APK=%CURRENT_PATH%\temp.apk
|
|
REM android替换文件夹
|
|
SET Android_PREFIX=%CURRENT_PATH%\AndroidFiles
|
|
|
|
REM 循环用证书重签名
|
|
set "x=0"
|
|
|
|
:RESIGN
|
|
if defined KEYSTORE_NAME[%x%] (
|
|
REM 创建临时文件夹
|
|
RD /S /Q %TEMP_PATH%
|
|
MD %TEMP_PATH%
|
|
|
|
REM 将apk移动到临时文件夹
|
|
COPY %CURRENT_PATH%\%SOURCE_APK% %TEMP_PATH%
|
|
REM 进入临时文件夹
|
|
CD %TEMP_PATH%
|
|
REM 解压APK文件
|
|
jar -xf %CURRENT_PATH%\%SOURCE_APK%
|
|
REM 删除移入临时文件夹的apk
|
|
DEL %TEMP_PATH%\%SOURCE_APK%
|
|
REM 删除MATA-INF
|
|
RD /S /Q %TEMP_PATH%\META-INF
|
|
|
|
for /F %%i in ('Dir %Android_PREFIX%\*.luac /B') do (
|
|
for /r %%j in (*@%%i) do (
|
|
COPY %Android_PREFIX%\%%i %%j
|
|
)
|
|
)
|
|
for /F %%i in ('Dir %Android_PREFIX%\*.* /B') do (
|
|
for /R %%j in (%%i) do (
|
|
if exist %%j (
|
|
COPY %Android_PREFIX%\%%i %%j
|
|
)
|
|
)
|
|
)
|
|
|
|
REM 重新压缩apk文件,将temp目录下的所有文件都打到temp.apk的包下
|
|
jar -cf %TEMP_APK% ./
|
|
REM 返回文件夹
|
|
cd %CURRENT_PATH%
|
|
call ECHO [%%KEYSTORE_ALIAS[%X%]%% 在重签名 %SOURCE_APK%]
|
|
call SET TARGET_APP_NAME=%CURRENT_PATH%\%%KEYSTORE_ALIAS[%X%]%%_%SOURCE_APK%
|
|
call echo %apksigner% sign %mOption% --ks %%KEYSTORE_NAME[%x%]%% -ks-key-alias %%KEYSTORE_ALIAS[%X%]%% --ks-pass pass:%%KEYSTORE_KEYPASS[%x%]%% --out %TARGET_APP_NAME% %TEMP_APK%
|
|
call %apksigner% sign %mOption% --ks %%KEYSTORE_NAME[%x%]%% -ks-key-alias %%KEYSTORE_ALIAS[%X%]%% --ks-pass pass:%%KEYSTORE_KEYPASS[%x%]%% --out %TARGET_APP_NAME% %TEMP_APK%
|
|
REM 签名v2以上的名称可以开启,作用是检查签名等级,只签名v1开启下面这句会报错
|
|
REM call %apksigner% verify -v --print-certs %TARGET_APP_NAME%
|
|
rem 将上传apk脚本放在此处上传,apk路径为 %TARGET_APP_NAME%
|
|
rem apk对齐,v2签名后不可对齐
|
|
rem call SET ZIPALIGN_APP_NAME=%CURRENT_PATH%\ZIP_%%KEYSTORE_ALIAS[%X%]%%_%SOURCE_APK%
|
|
rem call %zipalign% -f 4 %TARGET_APP_NAME% %ZIPALIGN_APP_NAME%
|
|
rem call %zipalign% -c -f 4 %ZIPALIGN_APP_NAME%
|
|
set /a "x+=1"
|
|
GOTO :RESIGN
|
|
)
|
|
|
|
REM 删除临时文件
|
|
RD /S /Q %TEMP_PATH%
|
|
DEL %TEMP_APK%
|