目录:

目录结构

下载软件 (powershell命令未测试)

android developer下载commandlinetools

下载cmdline-tools,并解压到D:\Program Files\androidsdk-commandlinetools

Invoke-WebRequest -Uri https://googledownloads.cn/android/repository/commandlinetools-win-11076708_latest.zip -OutFile cmdline-tools.zip
Expand-Archive -Path cmdline-tools.zip -DestinationPath "D:\Program Files\androidsdk-commandlinetools"

D:\Program Files\androidsdk-commandlinetools\cmdline-tools目录下创建latest目录,并将D:\Program Files\androidsdk-commandlinetools\cmdline-tools目录下的文件(除了latest目录, 即bin lib NOTICE.txt source.properties)移动到D:\Program Files\androidsdk-commandlinetools\cmdline-tools\latest目录下。

New-Item -Path "D:\Program Files\androidsdk-commandlinetools\cmdline-tools" -Name "latest" -ItemType "directory"
Move-Item -Path "D:\Program Files\androidsdk-commandlinetools\cmdline-tools\bin" -Destination "D:\Program Files\androidsdk-commandlinetools\cmdline-tools\latest" -Recurse
Move-Item -Path "D:\Program Files\androidsdk-commandlinetools\cmdline-tools\lib" -Destination "D:\Program Files\androidsdk-commandlinetools\cmdline-tools\latest" -Recurse
Move-Item -Path "D:\Program Files\androidsdk-commandlinetools\cmdline-tools\NOTICE.txt" -Destination "D:\Program Files\androidsdk-commandlinetools\cmdline-tools\latest"
Move-Item -Path "D:\Program Files\androidsdk-commandlinetools\cmdline-tools\source.properties" -Destination "D:\Program Files\androidsdk-commandlinetools\cmdline-tools\latest"

查看可用的build-tools版本

&"D:\Program Files\androidsdk-commandlinetools\cmdline-tools\latest\bin\sdkmanager.bat" --list

安装build-tools

&"D:\Program Files\androidsdk-commandlinetools\cmdline-tools\latest\bin\sdkmanager.bat" "build-tools;35.0.0-rc4"

生成密钥

使用keytool生成密钥

&"D:\Program Files\androidsdk-commandlinetools\build-tools\35.0.0-rc4\keytool.exe" -genkeypair -v -keystore xixue.keystore -keyalg RSA -keysize 2048 -validity 36500 -alias xixue

查看密钥

&"D:\Program Files\androidsdk-commandlinetools\build-tools\35.0.0-rc4\keytool.exe" -list -v -keystore xixue.keystore

生成APK (未测试)

C:\Program Files\7-Zip\7z.exe将以下文件打包入*.apkassets目录

  • script.atc
  • script.lc
  • script.prop
  • script.rtd
  • script.uip
  • script.uis
Copy-Item APKTemplate.apk APK_Unsigned.apk
&"C:\Program Files\7-Zip\7z.exe" a APK_Unsigned.apk assets\*

签名

使用apksigner签名

&"D:\Program Files\androidsdk-commandlinetools\build-tools\35.0.0-rc4\apksigner.bat" sign --in APK_Unsigned.apk --out APK_Signed.apk --ks xixue.keystore --align-file-size

验证签名

&"D:\Program Files\androidsdk-commandlinetools\build-tools\35.0.0-rc4\apksigner.bat" verify --in APK_Signed.apk --verbose