android path 合并_Android叠加更新

本文介绍了如何在CentOS环境下使用bsdiff和bspatch工具生成和合并Android应用的增量更新包。详细步骤包括:安装依赖、生成补丁、Android端通过JNI调用native方法进行合并。此外,提供了Android端Java代码示例,用于执行合并操作。
摘要由CSDN通过智能技术生成

环境:

centos  android9 idea

步骤:

1.下载bsdiff

2.centos 安装

gcc

make

bzip2

bzip2-devel

命令

yum -y install gcc autoconf automake libtool make

yum -y install bzip2

yum -y install bzip2-devel

3.修改解压后bsdiff中Makefile文件.ifndef WITHOUT_MAN 和endif 缩进

4.在bsdiff中执行 make命令生成bsdiff和bspatch文件

5.生成合并差异包

生成   bsdiff   oldapk_path.apk  newapk_path.apk  patchName.patch

合并   bspatch oldapk_path.apk  newName_path.apk  patch_path.patch

以上为服务端

Android端

1.ndk新建个PatchUtil.java用与调用native方法

public class PatchUtils {

private static PatchUtils instance;

static {

System.loadLibrary("update");

}

public static PatchUtils getInstance(){

if(instance==null){

instance = new PatchUtils();

}

return instance;

}

/**

* native方法 使用路径为oldApkPath的Apk与路径为patchPath的补丁包合成一个新的apk存储与newApkPath

* 返回 0 成功

* @param oldApkPath   示例:/usr/old/old.apk

function(){ //外汇代理 http://www.fx61.com/ib.html

* @param newApkPath   示例:/usr/new/new.apk

* @param patchPath    示例:/usr/patch/patch_1.patch

* @return

*/

public static native int bspatch(String oldApkPath, String newApkPath, String patchPath);

}

配置java.h 和buildOS

3.使用javah命令生成头文件,会在jni文件夹下生成com_xxx_xxx_xxx.PatchUtils.h,

4.将bsdiff文件夹下载bspatch.c导入jni文件夹

5.下载bzip2导入jni文件夹,删除除了.c和.h的其他文件

修改bspatch.c

/*-

* Copyright 2003-2005 Colin Percival

* All rights reserved

*

* Redistribution and use in source and binary forms, with or without

* modification, are permitted providing that the following conditions

* are met:

* 1. Redistributions of source code must retain the above copyright

*    notice, this list of conditions and the following disclaimer.

* 2. Redistributions in binary form must reproduce the above copyright

*    notice, this list of conditions and the following disclaimer in the

*    documentation and/or other materials provided with the distribution.

*

* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR

* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED

* WARRANTIES O

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值