diff --git a/.travis.yml b/.travis.yml index 73192ef7..1f720399 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_install: - sudo apt-get update -qq - sudo apt-get install -qq libstdc++6:i386 lib32z1 expect - git submodule update --init --recursive -script: ./gradlew build fatJar proguard +script: ./gradlew build shadowJar proguard branches: only: - master diff --git a/INTERNAL.md b/INTERNAL.md index dc72bdbb..24e79772 100644 --- a/INTERNAL.md +++ b/INTERNAL.md @@ -33,11 +33,11 @@ For example for the `2.2.1` release. In order to maintain a clean slate. Run `gradlew clean` to start from a clean slate. Now lets build the new version. We should not have any new commits since the tagged commit. - ./gradlew build fatJar proguard release + ./gradlew build shadowJar proguard release The build should tell you what version you are building and it should match the commits you made previously. - ➜ Apktool git:(master) ./gradlew build fatJar proguard release + ➜ Apktool git:(master) ./gradlew build shadowJar proguard release Building RELEASE (master): 2.2.2 ### Testing the binary. diff --git a/brut.apktool/apktool-cli/build.gradle b/brut.apktool/apktool-cli/build.gradle index 517d73cf..60106618 100644 --- a/brut.apktool/apktool-cli/build.gradle +++ b/brut.apktool/apktool-cli/build.gradle @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -apply plugin: 'eu.appsatori.fatjar' +apply plugin: 'com.github.johnrengelman.shadow' dependencies { compile depends.commons_cli @@ -30,22 +30,20 @@ buildscript { } } -gradle.taskGraph.whenReady { - fatJar { +jar { manifest { - attributes("Main-Class": "brut.apktool.Main") + attributes 'Main-Class' : 'brut.apktool.Main' } - } } task cleanOutputDirectory(type: Delete) { - delete fileTree(dir: jar.destinationDir.getPath(), exclude: "apktool-cli.jar") + delete fileTree(dir: jar.destinationDir.getPath(), exclude: "apktool-cli-all.jar") } -task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) { +task proguard(type: proguard.gradle.ProGuardTask, dependsOn: shadowJar) { def outFile = jar.destinationDir.getPath() + '/' + "apktool" + '-' + project.apktool_version + '-small' + '.' + jar.extension - injars fatJar.archivePath + injars shadowJar.archivePath outjars outFile libraryjars "${System.properties['java.home']}/lib/rt.jar" @@ -54,7 +52,6 @@ task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) { dontoptimize keep 'public class brut.apktool.Main { public static void main(java.lang.String[]); }' - keep 'class org.yaml.snakeyaml.** { public protected private *; }' keepclassmembers 'enum * { public static **[] values(); public static ** valueOf(java.lang.String); }' dontwarn 'com.google.common.base.**' dontwarn 'com.google.common.collect.**' diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResPluralsValue.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResPluralsValue.java index 31f6f952..ced53fbf 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResPluralsValue.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResPluralsValue.java @@ -50,11 +50,9 @@ public class ResPluralsValue extends ResBagValue implements continue; } - ResScalarValue rawValue = item; - serializer.startTag(null, "item"); serializer.attribute(null, "quantity", QUANTITY_MAP[i]); - serializer.text(ResXmlEncoders.enumerateNonPositionalSubstitutionsIfRequired(item.encodeAsResXmlValue())); + serializer.text(ResXmlEncoders.enumerateNonPositionalSubstitutionsIfRequired(item.encodeAsResXmlNonEscapedItemValue())); serializer.endTag(null, "item"); } serializer.endTag(null, "plurals"); diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/util/ExtMXSerializer.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/util/ExtMXSerializer.java index 5e15985f..8efa5bb7 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/util/ExtMXSerializer.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/util/ExtMXSerializer.java @@ -17,7 +17,7 @@ package brut.androlib.res.util; import java.io.*; -import org.xmlpull.mxp1_serializer.MXSerializer; +import org.xmlpull.renamed.MXSerializer; /** * @author Ryszard Wiśniewski diff --git a/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java b/brut.apktool/apktool-lib/src/main/java/org/xmlpull/renamed/MXSerializer.java similarity index 99% rename from brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java rename to brut.apktool/apktool-lib/src/main/java/org/xmlpull/renamed/MXSerializer.java index 66c69574..1adc9436 100644 --- a/brut.apktool/apktool-lib/src/main/java/org/xmlpull/mxp1_serializer/MXSerializer.java +++ b/brut.apktool/apktool-lib/src/main/java/org/xmlpull/renamed/MXSerializer.java @@ -1,4 +1,4 @@ -package org.xmlpull.mxp1_serializer; +package org.xmlpull.renamed; import java.io.IOException; import java.io.OutputStream; @@ -440,8 +440,8 @@ public class MXSerializer implements XmlSerializer { // check that prefix is not duplicated ... for (int i = elNamespaceCount[depth]; i < namespaceEnd; i++) { if (prefix == namespacePrefix[i]) { - throw new IllegalStateException("duplicated prefix " - + printable(prefix) + getLocation()); + // Toss out extra namespaces at same depth to fix #1456 + return; } } diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/VectorDrawableTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/VectorDrawableTest.java new file mode 100644 index 00000000..bc229b1f --- /dev/null +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/VectorDrawableTest.java @@ -0,0 +1,71 @@ +/** + * Copyright 2014 Ryszard Wiśniewski + * Copyright 2014 Connor Tumbleson + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package brut.androlib; + +import brut.common.BrutException; +import brut.directory.ExtFile; +import brut.util.OS; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.util.logging.Logger; + +import static org.junit.Assert.assertTrue; + +public class VectorDrawableTest { + + @BeforeClass + public static void beforeClass() throws Exception { + TestUtils.cleanFrameworkFile(); + sTmpDir = new ExtFile(OS.createTempDirectory()); + TestUtils.copyResourceDir(VectorDrawableTest.class, "brut/apktool/issue1456/", sTmpDir); + } + + @AfterClass + public static void afterClass() throws BrutException { + OS.rmdir(sTmpDir); + } + + @Test + public void checkIfDrawableFileDecodesProperly() throws BrutException, IOException { + String apk = "issue1456.apk"; + + // decode issue1456.apk + ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk)); + sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out"); + + apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out")); + apkDecoder.decode(); + + checkFileExists("res/drawable/ic_arrow_drop_down_black_24dp.xml"); + checkFileExists("res/drawable/ic_android_black_24dp.xml"); + } + + private void checkFileExists(String path) throws BrutException { + File f = new File(sTestOrigDir, path); + + assertTrue(f.isFile()); + } + + private static ExtFile sTmpDir; + private static ExtFile sTestOrigDir; + + private final static Logger LOGGER = Logger.getLogger(VectorDrawableTest.class.getName()); +} diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/issue1456/issue1456.apk b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/issue1456/issue1456.apk new file mode 100644 index 00000000..4eb5d499 Binary files /dev/null and b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/issue1456/issue1456.apk differ diff --git a/build.gradle b/build.gradle index 4346cf05..ba3f344f 100644 --- a/build.gradle +++ b/build.gradle @@ -21,17 +21,16 @@ buildscript { options.encoding = "UTF-8" } dependencies { - classpath 'eu.appsatori:gradle-fatjar-plugin:0.3' + classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4' } } -apply plugin: 'maven' apply from: 'gradle/functions.gradle' def apktoolversion_major = '2.2.3' def apktoolversion_minor = 'SNAPSHOT'; -defaultTasks 'build', 'fatJar', 'proguard' +defaultTasks 'build', 'shadowJar', 'proguard' allprojects { apply plugin: 'java' @@ -80,8 +79,6 @@ task release { subprojects { apply plugin: 'java' - apply plugin: 'maven' - apply plugin: 'idea' ext { depends = [ diff --git a/scripts/travis-ci/run-tests.sh b/scripts/travis-ci/run-tests.sh index 347df4f6..563869ce 100755 --- a/scripts/travis-ci/run-tests.sh +++ b/scripts/travis-ci/run-tests.sh @@ -1,2 +1,2 @@ #!/usr/bin/env sh -./gradlew build fatJar +./gradlew build shadowJar