shwenzhang / AndResGuard

proguard resource for Android by wechat team
Apache License 2.0
8.54k stars 1.54k forks source link

Mac 10.11.1 无法使用7z打包 #35

Closed atship closed 8 years ago

atship commented 8 years ago

hi, 使用brew install p7zip编译安装的 7z 7za已经躺在/usr/local/bin目录下了,terminal已经可以直接调用7za Android Studio中调用generate,可以生成app-rlease_signed.apk包 然后使用7z打包的时候,报错如下

general unsigned apk: app-release_unsigned.apk
DestResDir 698 rawResDir 698
signing apk: app-release_signed.apk
use 7zip to repackage: app-release_signed_7zip.apk, will cost much more time
general the raw 7zip file

java.io.IOException: Cannot run program "7za": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
    at java.lang.Runtime.exec(Runtime.java:617)
    at java.lang.Runtime.exec(Runtime.java:450)
    at java.lang.Runtime.exec(Runtime.java:347)
    at com.tencent.mm.androlib.ResourceApkBuilder.generalRaw7zip(ResourceApkBuilder.java:268)
    at com.tencent.mm.androlib.ResourceApkBuilder.use7zApk(ResourceApkBuilder.java:77)
    at com.tencent.mm.androlib.ResourceApkBuilder.buildApk(ResourceApkBuilder.java:47)
    at com.tencent.mm.resourceproguard.Main.buildApk(Main.java:93)
    at com.tencent.mm.resourceproguard.Main.resourceProguard(Main.java:70)
    at com.tencent.mm.resourceproguard.Main.run(Main.java:42)
    at com.tencent.mm.resourceproguard.Main.gradleRun(Main.java:36)

gradle配置如下

andResGuard {
    mappingFile = null
    use7zip = true
    keepRoot = false
    whiteList = [
            "com.ourapp.app.R.mipmap-xxhdpi.ic_launcher.png"
    ]
    compressFilePattern = [
            "*.png",
            "*.jpg",
            "*.jpeg",
            "*.gif",
            "resources.arsc"
    ]
}

而且gradle中貌似没有办法配置7z的路径,不知道有什么好办法可以处理这个问题

simpleton commented 8 years ago

@atship 由于大家启动as基本不会带user目录下的环境变量,这里我更新了下,把这种依赖环境变量的参数都配置在build.gradle里了,可以参照1.1.1的readme增加一下7zip的路径。麻烦验证一下,我这里测试没有问题。

brucetoo commented 8 years ago

windows ,用1.1.1版本加上 7za 命令行版本

sevenZipPath = "D:\\AndroidSDK\\7za\\7za.exe"

Log 输出路径OK,在命令行中能执行,但是任然报错

java.io.IOException: Cannot run program "7za": CreateProcess error=2, ?????????
atship commented 8 years ago

@simpleton 测试了以后,报的错还是一样的,如下

use7zip = true
 metaName = META-INF
 keepRoot = false
 whiteList = [com.privacy.applock.R.mipmap-xxhdpi.ic_launcher.png]
 compressFilePattern = [*.png, *.jpg, *.jpeg, *.gif, resources.arsc]
 zipAlignPath = zipalign
 7zipPath = /usr/local/bin/7za
        resourceprpguard begin
unziping apk to /Users/song/Documents/works/applock/app/build/outputs/apk/AndResProguard/temp
decoding resources.arsc
parse to get the exist names in the resouces.arsc first
reading packagename com.privacy.applock
resources mapping file /Users/song/Documents/works/applock/app/build/outputs/apk/AndResProguard/resource_mapping_app-release.txt done
writing new resources.arsc 
resources.arsc Character Encoding: utf-8
general unsigned apk: app-release_unsigned.apk
DestResDir 698 rawResDir 698
signing apk: app-release_signed.apk
use 7zip to repackage: app-release_signed_7zip.apk, will cost much more time
general the raw 7zip file

java.io.IOException: Cannot run program "7za": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
    at java.lang.Runtime.exec(Runtime.java:617)
    at java.lang.Runtime.exec(Runtime.java:450)
    at java.lang.Runtime.exec(Runtime.java:347)
    at com.tencent.mm.androlib.ResourceApkBuilder.generalRaw7zip(ResourceApkBuilder.java:265)
    at com.tencent.mm.androlib.ResourceApkBuilder.use7zApk(ResourceApkBuilder.java:77)
    at com.tencent.mm.androlib.ResourceApkBuilder.buildApk(ResourceApkBuilder.java:47)
    at com.tencent.mm.resourceproguard.Main.buildApk(Main.java:97)
    at com.tencent.mm.resourceproguard.Main.resourceProguard(Main.java:74)
    at com.tencent.mm.resourceproguard.Main.run(Main.java:43)
    at com.tencent.mm.resourceproguard.Main.gradleRun(Main.java:37)
simpleton commented 8 years ago

@atship 抱歉,请更新到1.1.2再试下,我上一个commit没有修好。由于我本地对as配置了环境变量,所以没有发现问题。

atship commented 8 years ago

@simpleton 非常感谢,一切OK