Skip to content

Commit 4bf0b6f

Browse files
1.7.2
Improve UI Use https://github.com/MuntashirAkon/apksig-android to sign with V1 + V2 + V3
1 parent f8b3d30 commit 4bf0b6f

File tree

179 files changed

+32233
-327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+32233
-327
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId = "com.abdurazaaqmohammed.androidmanifesteditor"
1111
minSdk = 1
1212
targetSdk = 35
13-
versionCode = 11
14-
versionName = "1.6.2"
13+
versionCode = 19
14+
versionName = "1.7.2"
1515

1616
}
1717

app/src/androidTest/java/com/abdurazaaqmohammed/androidmanifesteditor/ExampleInstrumentedTest.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/src/main/assets/debug.keystore

2.56 KB
Binary file not shown.

app/src/main/assets/testkey.past

1.42 KB
Binary file not shown.

app/src/main/assets/testkey.pk8

1.19 KB
Binary file not shown.

app/src/main/java/com/abdurazaaqmohammed/androidmanifesteditor/main/MainActivity.java

Lines changed: 150 additions & 77 deletions
Large diffs are not rendered by default.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.abdurazaaqmohammed.androidmanifesteditor.main;
2+
3+
import android.content.Context;
4+
5+
import com.android.apksig.ApkSigner;
6+
import com.android.apksig.apk.ApkFormatException;
7+
8+
import java.io.File;
9+
import java.io.IOException;
10+
import java.io.InputStream;
11+
import java.security.InvalidKeyException;
12+
import java.security.KeyStore;
13+
import java.security.KeyStoreException;
14+
import java.security.NoSuchAlgorithmException;
15+
import java.security.SignatureException;
16+
import java.security.UnrecoverableEntryException;
17+
import java.security.cert.CertificateException;
18+
import java.security.cert.X509Certificate;
19+
import java.util.Collections;
20+
21+
public class SignUtil {
22+
public static void signApk(InputStream key, String password, File inputApk, File output) throws KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException, ApkFormatException, SignatureException, InvalidKeyException, UnrecoverableEntryException {
23+
signApk(key, password, inputApk, output, true, true, true);
24+
}
25+
26+
public static void signApk(InputStream key, String password, File inputApk, File output, boolean v1, boolean v2, boolean v3) throws KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException, ApkFormatException, SignatureException, InvalidKeyException, UnrecoverableEntryException {
27+
char[] pw = password.toCharArray();
28+
29+
KeyStore keystore = KeyStore.getInstance("PKCS12");
30+
keystore.load(key, pw);
31+
32+
String alias = keystore.aliases().nextElement();
33+
34+
new ApkSigner.Builder(Collections.singletonList(new ApkSigner.SignerConfig.Builder("CERT",
35+
((KeyStore.PrivateKeyEntry) keystore.getEntry(alias, new KeyStore.PasswordProtection(pw))).getPrivateKey(),
36+
Collections.singletonList((X509Certificate) keystore.getCertificate(alias))).build()))
37+
.setInputApk(inputApk)
38+
.setOutputApk(output)
39+
.setCreatedBy("Android Gradle 8.0.2")
40+
.setV1SigningEnabled(v1)
41+
.setV2SigningEnabled(v2)
42+
.setV3SigningEnabled(v3).build().sign();
43+
}
44+
45+
public static void signDebugKey(Context c, File inputApk, File output, boolean v1, boolean v2, boolean v3) throws IOException, ApkFormatException, UnrecoverableEntryException, CertificateException, KeyStoreException, NoSuchAlgorithmException, SignatureException, InvalidKeyException {
46+
SignUtil.signApk(c.getAssets().open("debug.keystore"), "android", inputApk, output, v1, v2, v3);
47+
}
48+
49+
public static void signDebugKey(Context c, File inputApk, File output) throws IOException, ApkFormatException, UnrecoverableEntryException, CertificateException, KeyStoreException, NoSuchAlgorithmException, SignatureException, InvalidKeyException {
50+
SignUtil.signApk(c.getAssets().open("debug.keystore"), "android", inputApk, output);
51+
}
52+
}

0 commit comments

Comments
 (0)