patrickfav / uber-apk-signer

A cli tool that helps signing and zip aligning single or multiple Android application packages (APKs) with either debug or provided release certificates. It supports v1, v2 and v3 Android signing scheme has an embedded debug keystore and auto verifies after signing.
https://favr.dev/opensource/uber-apk-signer
Apache License 2.0
1.9k stars 197 forks source link

Unnecessary external com.android:apksigner dependency #48

Open rob-X1 opened 11 months ago

rob-X1 commented 11 months ago

pom.xml contains the system dependency

        <dependency>
            <groupId>com.android</groupId>
            <artifactId>apksigner</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/apksigner_33_0_2.jar</systemPath>
        </dependency>

which makes building uber-apk-signer unnecessary complicated. Google releases the library version of apksigner in it's maven repository: https://mvnrepository.com/artifact/com.android.tools.build/apksig?repo=google

So you only have to add

    <repositories>
        <repository>
            <id>Google</id>
            <name>Google</name>
            <url>https://maven.google.com/</url>
        </repository>
    </repositories>

and then use the dependency

<dependency>
    <groupId>com.android.tools.build</groupId>
    <artifactId>apksig</artifactId>
    <version>8.0.2</version>
</dependency>

You can then directly com.android.apksig.ApkSigner and com.android.apksig.ApkVerifier within your code.

patrickfav commented 11 months ago

Good point, didnt know that, thank you!

Will change it to an non-system depdency!

patrickfav commented 11 months ago

So, currently Im using the com.android.apksigner.ApkSignerTool as interface with the signer, which is basically using it as CLI. The dependency only has the internal signer code, without the CLI interface, so I need to refactor the code a bit (thecom.android.apksig.ApkSigner interface is not super trivial)

rob-X1 commented 11 months ago

You can use the original ApkSigner source code to see what parameter causes what code to be executed: https://android.googlesource.com/platform/tools/apksig/+/refs/heads/main/src/apksigner/java/com/android/apksigner/ApkSignerTool.java