npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apk-revise

v1.0.7

Published

用于反编译APK文件,修改资源文件后重新打包、签名。目前主要用途用于修改AndroidManifest.xml的meta-data数据(添加渠道等信息),也可用于其他修改。

Downloads

12

Readme

APK-REVISE

用于反编译APK文件,修改资源文件后重新打包、签名。目前主要用途用于修改AndroidManifest.xml的meta-data数据(添加渠道等信息),也可用于其他修改。 拥有两种使用方式,命令行方式和自定义方式。反编译和重新打包使用的是apktool,然后使用zipalign和apksigner。

安装

npm install apk-revise

警示: 系统需安装Java(作者Java版本21.0.1),Node版本需大于20.11.0。

命令行方式

npx apk-revise -e=./app.apk?rename=new_app -o=./build -s=./证书.keystore -a=证书别名 -p=证书密码 -rm=./channel.json

/* ./channel.json */
{
  "huawei": [
    {
      "name": "CHANNEL_NAME", /* meta-data的name */
      "value": "huawei", /* meta-data的value */
      "merge": false /* 当name为CHANNEL_NAME的meta-data存在时,是替换还是合并原有值 */
    }
  ],
  "xiaomi": [{ "name": "CHANNEL_NAME", "value": "xiaomi", "merge": false }]
}

npx apk-revise -e=./app.apk?rename=new_app -o=./build -s=./证书.keystore -a=证书别名 -p=证书密码 -rs=./revise.js

// ./revise.js
export default {
  count: 1, // 修改打包次数
  reviseData: async (instance, index) => {
    // 反编译后资源目录
    const dir = await instance.getReviseDirPath()

    // 自己的修改方法
  },
  outputFilePath: async (instance, index) => {
    // 导出路径
    return './new_app.apk'
  }
}

自定义方式

警示:自定义方式项目中的package.json需添加"type": "module"

import { ReviseUtensil } from 'apk-revise'

// 配置
const reviseUtensil = new ReviseUtensil({
  target: async (instance) => {
    return {
      count: 1, // 修改打包次数
      reviseData: async (instance, index) => {
        // 反编译后资源目录
        const dir = await instance.getReviseDirPath()

        // 自己的修改方法
      },
      outputFilePath: async (instance, index) => {
        // 导出路径
        return './new_app.apk'
      }
    }
  },
  file: async (instance) => {
    return {
      entryFilePath: './app.apk', // 原始apk文件
      outputDirPath: './build', // 导出目录
      isCreateReplica: true, // 是否创建资源副本,避免多次修改打包的相互影响
    }
  },
  key: async (instance) => {
    return {
      ks: './证书.keystore',
      ksKeyAlias: '表示signer在密钥库中的私钥和证书数据的别名的名称',
      ksPass: '包含signer私钥和证书的密钥库的密码',
      keyPass?: 'signer私钥的密码',
    }
  },
  // 环境变量中配置了java、zipalign和apksigner那env可不写
  env: async (instance) => {
    return {
      java: '系统java路径',
      zipalign: '系统zipalign路径',
      apksigner: '系统apksigner路径',
    }
  }
})

// 日志
reviseUtensil.on('process_stdout', (name, msg) => {
  console.log('主进程输出', name, msg)
})
reviseUtensil.on('subprocess_stdout', (name, msg) => {
  console.log('子进程输出', name, msg)
})
reviseUtensil.on('subprocess_stderr', (name, msg) => {
  console.log('子进程异常', name, msg)
})

// 开始执行
const apkPathList = await reviseUtensil.run()
console.log(apkPathList)