# ApkPublish **Repository Path**: lixiuze/apk-publish ## Basic Information - **Project Name**: ApkPublish - **Description**: Android APP 一键加固、签名、渠道打包工具 - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2023-09-04 - **Last Updated**: 2023-09-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ApkPublish #### 介绍 ApkPublish 是一个集 安卓app 加固、渠道、签名于一体的程序,加固使用乐固服务,贵在免费😄。 [Windows二进制包下载](https://gitee.com/11261126/apk-publish/releases) **生成的安装包均在程序根目录下的文件夹( **版本号-版本名称** )中,渠道包在二级文件夹channel中,签名包在二级文件夹sign中** 如图: ![输入图片说明](%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20230331160024.png) #### 使用说明 ##### 二进制包使用 1. 修改配置config.ini文件(程序根目录下) 2. 运行程序main.exe(程序根目录下) 3. **二进制包** 命令行窗口一闪而过,说明配置文件有问题,请检查配置文件 ##### 源码使用 1. pip install -r requirements.txt 2. 修改配置文件(程序根目录下config.ini文件) 3. 运行程序 #### 配置文件说明 ``` [appInfo] #app配置信息 apk_download_path = https://xxx.com/xxxx.apk #app原始包下载链接(必须公网可访问) app_version_name = 1001 #版本名称(只涉及生成安装包时的文件夹使用) app_version_code = v1.1.0 #版本号(只涉及生成安装包时的文件夹使用) [lib] # Android & Java环境配置信息 build_tools_path = D:\SDK\Android\build-tools\28.0.3 #build-tools文件夹路径(建议使用28.0.3) java_home = C:\Program Files\Java\jdk-11.0.13 #JavaHome路径 [channelInfo] #渠道包配置信息 prefix = channel- #渠道包前缀 channel = huawei,xiaomi,sanxing #渠道信息,英文逗号分隔 [signInfo] #签名配置信息 storeFile = D:\xxxx\xxx.jks #签名密钥 keyAlias = xxx #密钥别名 keyPassword = xxx #别名密码 storePassword = xxx #密钥密码 [leguInfo] #乐固配置信息,请前往腾讯云开启服务https://cloud.tencent.com/product/ms ak = xxxxxxxxxxxxxxx #api访问SecretId 前往新建https://console.cloud.tencent.com/cam/capi sk = xxxxxxxxxxxxxx #api访问SecretKey 前往新建https://console.cloud.tencent.com/cam/capi ``` #### Android读取渠道代码 ``` /** * 从apk中获取版本信息 * @param context * @param channelPrefix 渠道前缀 * @return */ fun getChannelFromApk(context: Context, channelPrefix: String): String? { //从apk包中获取 val appinfo = context.applicationInfo val sourceDir = appinfo.sourceDir //默认放在meta-inf/里, 所以需要再拼接一下 val key = "META-INF/$channelPrefix" var ret = "" var zipfile: ZipFile? = null try { zipfile = ZipFile(sourceDir) val entries: Enumeration<*> = zipfile.entries() while (entries.hasMoreElements()) { val entry = entries.nextElement() as ZipEntry val entryName = entry.name if (entryName.startsWith(key)) { ret = entryName break } } } catch (e: IOException) { e.printStackTrace() } finally { if (zipfile != null) { try { zipfile.close() } catch (e: IOException) { e.printStackTrace() } } } val split = ret.split(channelPrefix.toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() var channel = "" if (split != null && split.size >= 2) { channel = ret.substring(key.length) } return channel } ```