首页 > 其他分享 >修改Android的apk包

修改Android的apk包

时间:2023-05-14 10:57:01浏览次数:42  
标签:files 修改 -- jar apk framework apktool Android

解包

使用apktool工具,对apk进行反编译并解包   注:需使用java1.8来执行jar包

set PATH=E:\NVPACK\jdk1.8.0_77\bin;%PATH%
java -jar %~dp0\apktool\apktool.jar d D:\MyTest1-Android-Test-arm64.apk  // 对MyTest1-Android-Test-arm64.pak进行解包

 

如果不需要反编译java代码,需带上-s参数;不需要反编译资源,需带上-r参数

set PATH=E:\NVPACK\jdk1.8.0_77\bin;%PATH%
java -jar %~dp0\apktool\apktool.jar d -s -r D:\MyTest1-Android-Test-arm64.apk  // 不反编译java代码和资源,来对MyTest1-Android-Test-arm64.pak进行解包

 

apktool使用说明详见:

F:\GameRepack\apktool\apktool>set PATH=E:\NVPACK\jdk1.8.0_77\bin;%PATH%

F:\GameRepack\apktool\apktool>java -jar apktool.jar
Apktool v2.5.0 - a tool for reengineering Android apk files
with smali v2.4.0 and baksmali v2.4.0
Copyright 2010 Ryszard Wi?niewski <[email protected]>
Copyright 2010 Connor Tumbleson <[email protected]>

usage: apktool
 -advance,--advanced   prints advance information.
 -version,--version    prints the version then exits
usage: apktool if|install-framework [options] <framework.apk>
 -p,--frame-path <dir>   Stores framework files into <dir>.
 -t,--tag <tag>          Tag frameworks using <tag>.
usage: apktool d[ecode] [options] <file_apk>
 -f,--force              Force delete destination directory.
 -o,--output <dir>       The name of folder that gets written. Default is apk.out
 -p,--frame-path <dir>   Uses framework files located in <dir>.
 -r,--no-res             Do not decode resources.
 -s,--no-src             Do not decode sources.
 -t,--frame-tag <tag>    Uses framework files tagged by <tag>.
usage: apktool b[uild] [options] <app_path>
 -f,--force-all          Skip changes detection and build all files.
 -o,--output <dir>       The name of apk that gets written. Default is dist/name.apk
 -p,--frame-path <dir>   Uses framework files located in <dir>.

For additional info, see: https://ibotpeaches.github.io/Apktool/
For smali/baksmali info, see: https://github.com/JesusFreke/smali

 

apktool更详细的使用说明:

F:\GameRepack\apktool\apktool>java -jar apktool.jar -advance
Apktool v2.5.0 - a tool for reengineering Android apk files
with smali v2.4.0 and baksmali v2.4.0
Copyright 2010 Ryszard Wi?niewski <[email protected]>
Copyright 2010 Connor Tumbleson <[email protected]>
Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0)

usage: apktool [-q|--quiet OR -v|--verbose]
 -advance,--advanced   prints advance information.
 -version,--version    prints the version then exits
usage: apktool [-q|--quiet OR -v|--verbose] if|install-framework [options] <framework.apk>
 -p,--frame-path <dir>   Stores framework files into <dir>.
 -t,--tag <tag>          Tag frameworks using <tag>.
usage: apktool [-q|--quiet OR -v|--verbose] d[ecode] [options] <file_apk>
 -api,--api-level <API>   The numeric api-level of the file to generate, e.g. 14 for ICS.
 -b,--no-debug-info       don't write out debug info (.local, .param, .line, etc.)
 -f,--force               Force delete destination directory.
    --force-manifest      Decode the APK's compiled manifest, even if decoding of resources is set to "false".
 -k,--keep-broken-res     Use if there was an error and some resources were dropped, e.g.
                          "Invalid config flags detected. Dropping resources", but you
                          want to decode them anyway, even with errors. You will have to
                          fix them manually before building.
 -m,--match-original      Keeps files to closest to original as possible. Prevents rebuild.
    --no-assets           Do not decode assets.
 -o,--output <dir>        The name of folder that gets written. Default is apk.out
    --only-main-classes   Only disassemble the main dex classes (classes[0-9]*.dex) in the root.
 -p,--frame-path <dir>    Uses framework files located in <dir>.
 -r,--no-res              Do not decode resources.
 -s,--no-src              Do not decode sources.
 -t,--frame-tag <tag>     Uses framework files tagged by <tag>.
usage: apktool [-q|--quiet OR -v|--verbose] b[uild] [options] <app_path>
 -a,--aapt <loc>          Loads aapt from specified location.
 -api,--api-level <API>   The numeric api-level of the file to generate, e.g. 14 for ICS.
 -c,--copy-original       Copies original AndroidManifest.xml and META-INF. See project page for more info.
 -d,--debug               Sets android:debuggable to "true" in the APK's compiled manifest
 -f,--force-all           Skip changes detection and build all files.
 -nc,--no-crunch          Disable crunching of resource files during the build step.
 -o,--output <dir>        The name of apk that gets written. Default is dist/name.apk
 -p,--frame-path <dir>    Uses framework files located in <dir>.
    --use-aapt2           Upgrades apktool to use experimental aapt2 binary.
usage: apktool [-q|--quiet OR -v|--verbose] publicize-resources <file_path>

usage: apktool [-q|--quiet OR -v|--verbose] empty-framework-dir [options]
 -f,--force              Force delete destination directory.
 -p,--frame-path <dir>   Stores framework files into <dir>.
usage: apktool [-q|--quiet OR -v|--verbose] list-frameworks [options]
 -p,--frame-path <dir>   Stores framework files into <dir>.

For additional info, see: https://ibotpeaches.github.io/Apktool/
For smali/baksmali info, see: https://github.com/JesusFreke/smali

 

打包

使用apktool将某个目录打包成apk

set PATH=E:\NVPACK\jdk1.8.0_77\bin;%PATH%
java -jar %~dp0\apktool\apktool.jar b D:\MyTest1-Android-Test-arm64  // 将D:\MyTest1-Android-Test-arm64目录中的文件打包成apk

 

重签名

使用build-tools中的apksigner.bat工具对apk进行重签名

set PATH=E:\NVPACK\jdk1.8.0_77\bin;%PATH%
set ApkSigner=E:\NVPACK\android-sdk-windows\build-tools\27.0.3\apksigner.bat
set GameKeyStore=D:\Test1-key.keystore
set GamePassword=Test111
set AnlignedName=Test1
java -Xmx4096M -Xss4m -Djava.ext.dirs="%ApkSignerDir%" -jar "%ApkSignerDir%\apksigner.jar" sign --ks %GameKeyStore% --ks-pass pass:%GamePassword% --ks-key-alias %AnlignedName% --in %~dp0\MyTest1-Android-Test-arm64\dist\MyTest1-Android-Test-arm64.apk --out %~dp0\MyTest1-Android-Test-arm64_signed.apk

注1:build-tools 27.0.3可以从这里下载 

注2:由于apk有2GB,size比较大,会导致java进程崩溃,因此通过-Xmx来设置最大java堆的大小,通过-Xss设置java线程栈的大小

 

对于keystore秘钥可使用jdk1.8中的keytool工具来创建

set PATH=E:\NVPACK\jdk1.8.0_77\bin;%PATH%
keytool -genkey -v -keystore Test1-key.keystore -alias Test1 -keyalg RSA -keysize 2048 -validity 100000

 

标签:files,修改,--,jar,apk,framework,apktool,Android
From: https://www.cnblogs.com/kekec/p/17398844.html

相关文章

  • 解决Qt6.5 for Android应用程序(地图应用程序)不支持OpenSSL问题
    1.问题原因:版本问题ssl_3:usedforQt6.5.0+.ssl_1_1:forQtQt5.12.5+,5.13.1+,5.14.0+,5.15.0+,Qt6.x.xupto6.4.x2.解决方法在此网址https://github.com/KDAB/android_openssl,下载预编译库android_openssl-master.zip,并按照说明使用。 参考地址:0.Addi......
  • Ubuntu下安装Android Studio
    一、系统环境二、安装源文件AndroidStudio4.2.2:android-studio-ide-202.7486908-linux.tar.gzJavaSEDevelopmentKit:jdk-8u221-linux-x64.tar.gz提取码:17xx三、安装JDK解压JDK:sudotar-zxvfjdk-8u221-linux-x64.tar.gz-C/opt配置环境变量:sudogedit/etc/pr......
  • Android Ble蓝牙出现以下错误:E/BluetoothGatt:android.os.DeadObjectException
    造成以下错误的操作主要是:Ble蓝牙先连接成功,连接成功之后断开蓝牙,蓝牙重新打开后,服务还未绑定完成,就去调用connect连接,导致的。大概意思就是某个对象已经不存在引起的异常。网上的解决方法方法:在application标签里面添加一句(对我来说没有用)android:hardwareAccelerated="false"(禁......
  • shell中任务递交后修改循环配置文件效果
     001、投递该任务(base)[b20223040323@admin1test]$lsa.txtrecord.sh(base)[b20223040323@admin1test]$cata.txt##循环配置文件110000000002500000000(base)[b20223040323@admin1test]$catrecord.sh##测试程序#!/bin/bashcata.......
  • JavaWeb过滤器读取并修改POST请求的参数-YhtHttpServletRequestWrapper
    核心原理就是一个类:javax.servlet.http.HttpServletRequestWrapper一个简单的例子,当任何请求的参数里有aaa的时候,把它的值改成bbb新增一个类自定义的类CustomHttpServletRequestWrapper importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpSer......
  • 修改Windows远程桌面的端口
    一、图形界面下修改启动注册表编辑器。(在“搜索”框中键入regedit。)导航到以下注册表子项:HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp查找端口号单击“编辑”>“修改”,然后单击“十进制”。键入新端口号,然后单击“确定”......
  • Halcon联合C#开发实用版框架,在2.0版本基础上做了修改的,实际项目应用过的版本,源码,修改
    Halcon联合C#开发实用版框架,在2.0版本基础上做了修改的,实际项目应用过的版本,源码,修改了很多Bug,自带有项目运行流程与图片,很适合学习使用,可修改参考用于项目。注:软件能够正常编译运行,使用中遇到Bug自行摸索解决,主要是源码学习参考为主。ID:2619656657567557......
  • java 的 JDK JRE , android 的 SDK NDK , native c++ 的概念
       ......
  • flutter Android SDK not configed
    https://stackoverflow.com/questions/64359564/error-java-home-is-not-set-and-no-java-command-could-be-found-in-your-flutterflutterconfig--android-studio-dir="C:\ProgramFiles\Android\AndroidStudio"......
  • 数据库修改端口
    数据库修改端口  1.修改数据库默认端口(自定义为5500)#修改Sqlserver默认端口为5500/opt/mssql/bin/mssql-confsetnetwork.tcpport5500 2.重启Sqlserver服务systemctlrestartmssql-server 3.防火墙放行修改的端口(云服务器添加入站规则即可)firewall-cmd--zo......