Skip to content

Commit 32ecf10

Browse files
committed
pluginapk add release proguard config
1 parent 3a44526 commit 32ecf10

File tree

11 files changed

+5155
-10
lines changed

11 files changed

+5155
-10
lines changed

app/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.classpath
33
.project
44
.settings
5-
proguard-merge-config.txt
5+
proguard-merge-config.txt
6+
mapping.txt

app/proguard-rules.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
#https://github.com/WrBug/FrenziedProguard
2424
# ----------------------------------------------------------------------------
2525
# 混淆的压缩比例,0-7 表示对代码进行迭代优化的次数,optimization可以对代码进行各种优化,每次优化后还可以继续优化,故称之迭代优化
26-
-optimizationpasses 7
26+
-dontoptimize
27+
-applymapping mapping.txt
2728

2829
# https://blog.csdn.net/wmadao11/article/details/102613078
2930
-allowaccessmodification
-2.09 MB
Binary file not shown.

build_debug_apk.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
./gradlew :pluginapk:clean && \
3+
./gradlew :pluginapk:assembleDebug && \
4+
cp pluginapk/build/outputs/apk/debug/pluginapk-debug.apk ./app/src/main/assets/pluginapk-debug.apk && \
5+
./gradlew :app:clean && \
6+
adb uninstall com.malin.plugin
7+
adb uninstall com.malin.hook
8+
./gradlew :app:installDebug && \
9+
adb shell am start com.malin.hook/.MainActivity

build_release_apk.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
./gradlew :pluginapk:clean && \
3+
./gradlew :pluginapk:assembleRelease && \
4+
cp pluginapk/build/outputs/apk/release/pluginapk-release.apk ./app/src/main/assets/pluginapk-debug.apk && \
5+
cp pluginapk/build/outputs/proguard/release/mapping/mapping.txt ./app/ && \
6+
./gradlew :app:clean && \
7+
./gradlew :app:assembleRelease && \
8+
adb uninstall com.malin.plugin
9+
adb uninstall com.malin.hook
10+
run.sh app/build/outputs/apk/release/app-release.apk
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
com.malin.plugin.PluginResourceUtil -> o.pv:
2+
# {"fileName":"PluginResourceUtil.java","id":"sourceFile"}
3+
android.content.res.Resources mResources -> O000000o
4+
15:21:android.content.res.Resources getResource(android.content.Context) -> O000000o
5+
27:40:android.content.res.Resources loadResource(android.content.Context) -> O00000Oo
6+
7+
8+
//插件apk中的 o.pv类
9+
package o;
10+
import android.content.Context;
11+
import android.content.res.AssetManager;
12+
import android.content.res.Resources;
13+
import java.io.File;
14+
import java.lang.reflect.Method;
15+
16+
/* loaded from: classes.dex */
17+
public class pv {
18+
private static Resources O000000o;
19+
20+
public static Resources O000000o(Context context) {
21+
if (O000000o == null) {
22+
Resources O00000Oo = O00000Oo(context);
23+
O000000o = O00000Oo;
24+
if (O00000Oo == null) {
25+
throw new NullPointerException("plugin Resources==null");
26+
}
27+
}
28+
return O000000o;
29+
}
30+
31+
private static Resources O00000Oo(Context context) {
32+
try {
33+
File fileStreamPath = context.getFileStreamPath("pluginapk-debug.apk");
34+
AssetManager assetManager = (AssetManager) AssetManager.class.newInstance();
35+
Method declaredMethod = assetManager.getClass().getDeclaredMethod("addAssetPath", String.class);
36+
declaredMethod.setAccessible(true);
37+
declaredMethod.invoke(assetManager, fileStreamPath.getAbsolutePath());
38+
Resources resources = context.getResources();
39+
return new Resources(assetManager, resources.getDisplayMetrics(), resources.getConfiguration());
40+
} catch (Exception e) {
41+
e.printStackTrace();
42+
return null;
43+
}
44+
}
45+
}
46+
47+
48+
//宿主apk中的 o.pv类
49+
package o;
50+
import android.content.Context;
51+
import android.os.Handler;
52+
import android.os.Message;
53+
import android.util.AttributeSet;
54+
import android.util.Log;
55+
import android.view.LayoutInflater;
56+
import android.view.View;
57+
import android.view.ViewGroup;
58+
import java.util.concurrent.ArrayBlockingQueue;
59+
import o.h;
60+
61+
/* loaded from: classes.dex */
62+
public final class pv {
63+
LayoutInflater O000000o;
64+
private Handler.Callback O00000o = new Handler.Callback() { // from class: o.pv.1
65+
@Override // android.os.Handler.Callback
66+
public boolean handleMessage(Message message) {
67+
O00000Oo o00000Oo = (O00000Oo) message.obj;
68+
if (o00000Oo.O00000o == null) {
69+
o00000Oo.O00000o = pv.this.O000000o.inflate(o00000Oo.O00000o0, o00000Oo.O00000Oo, false);
70+
}
71+
o00000Oo.O00000oO.onInflateFinished(o00000Oo.O00000o, o00000Oo.O00000o0, o00000Oo.O00000Oo);
72+
pv.this.O00000o0.O000000o(o00000Oo);
73+
return true;
74+
}
75+
};
76+
Handler O00000Oo = new Handler(this.O00000o);
77+
O00000o0 O00000o0 = O00000o0.O000000o();
78+
79+
/* loaded from: classes.dex */
80+
public interface O00000o {
81+
void onInflateFinished(View view, int i, ViewGroup viewGroup);
82+
}
83+
84+
public pv(Context context) {
85+
this.O000000o = new O000000o(context);
86+
}
87+
88+
public void O000000o(int i, ViewGroup viewGroup, O00000o o00000o) {
89+
if (o00000o == null) {
90+
throw new NullPointerException("callback argument may not be null!");
91+
}
92+
O00000Oo O00000o02 = this.O00000o0.O00000o0();
93+
O00000o02.O000000o = this;
94+
O00000o02.O00000o0 = i;
95+
O00000o02.O00000Oo = viewGroup;
96+
O00000o02.O00000oO = o00000o;
97+
this.O00000o0.O00000Oo(O00000o02);
98+
}
99+
100+
/* JADX INFO: Access modifiers changed from: package-private */
101+
/* loaded from: classes.dex */
102+
public static class O00000Oo {
103+
pv O000000o;
104+
ViewGroup O00000Oo;
105+
View O00000o;
106+
int O00000o0;
107+
O00000o O00000oO;
108+
109+
O00000Oo() {
110+
}
111+
}
112+
113+
/* loaded from: classes.dex */
114+
static class O000000o extends LayoutInflater {
115+
private static final String[] O000000o = {"android.widget.", "android.webkit.", "android.app."};
116+
117+
O000000o(Context context) {
118+
super(context);
119+
}
120+
121+
@Override // android.view.LayoutInflater
122+
public LayoutInflater cloneInContext(Context context) {
123+
return new O000000o(context);
124+
}
125+
126+
@Override // android.view.LayoutInflater
127+
protected View onCreateView(String str, AttributeSet attributeSet) throws ClassNotFoundException {
128+
View createView;
129+
for (String str2 : O000000o) {
130+
try {
131+
createView = createView(str, str2, attributeSet);
132+
} catch (ClassNotFoundException unused) {
133+
}
134+
if (createView != null) {
135+
return createView;
136+
}
137+
}
138+
return super.onCreateView(str, attributeSet);
139+
}
140+
}
141+
142+
/* loaded from: classes.dex */
143+
static class O00000o0 extends Thread {
144+
private static final O00000o0 O000000o;
145+
private ArrayBlockingQueue<O00000Oo> O00000Oo = new ArrayBlockingQueue<>(10);
146+
private h.O00000o0<O00000Oo> O00000o0 = new h.O00000o0<>(10);
147+
148+
private O00000o0() {
149+
}
150+
151+
static {
152+
O00000o0 o00000o0 = new O00000o0();
153+
O000000o = o00000o0;
154+
o00000o0.start();
155+
}
156+
157+
public static O00000o0 O000000o() {
158+
return O000000o;
159+
}
160+
161+
public void O00000Oo() {
162+
try {
163+
O00000Oo take = this.O00000Oo.take();
164+
try {
165+
take.O00000o = take.O000000o.O000000o.inflate(take.O00000o0, take.O00000Oo, false);
166+
} catch (RuntimeException e) {
167+
Log.w("AsyncLayoutInflater", "Failed to inflate resource in the background! Retrying on the UI thread", e);
168+
}
169+
Message.obtain(take.O000000o.O00000Oo, 0, take).sendToTarget();
170+
} catch (InterruptedException e2) {
171+
Log.w("AsyncLayoutInflater", e2);
172+
}
173+
}
174+
175+
@Override // java.lang.Thread, java.lang.Runnable
176+
public void run() {
177+
while (true) {
178+
O00000Oo();
179+
}
180+
}
181+
182+
public O00000Oo O00000o0() {
183+
O00000Oo O000000o2 = this.O00000o0.O000000o();
184+
return O000000o2 == null ? new O00000Oo() : O000000o2;
185+
}
186+
187+
public void O000000o(O00000Oo o00000Oo) {
188+
o00000Oo.O00000oO = null;
189+
o00000Oo.O000000o = null;
190+
o00000Oo.O00000Oo = null;
191+
o00000Oo.O00000o0 = 0;
192+
o00000Oo.O00000o = null;
193+
this.O00000o0.O000000o(o00000Oo);
194+
}
195+
196+
public void O00000Oo(O00000Oo o00000Oo) {
197+
try {
198+
this.O00000Oo.put(o00000Oo);
199+
} catch (InterruptedException e) {
200+
throw new RuntimeException("Failed to enqueue async inflate request", e);
201+
}
202+
}
203+
}
204+
}
205+
206+
207+
9778-9778 AndroidRuntime com.malin.hook E FATAL EXCEPTION: main
208+
Process: com.malin.hook, PID: 9778
209+
java.lang.NoSuchMethodError: No static method O000000o(Landroid/content/Context;)Landroid/content/res/Resources; in class Lo/pv; or its super classes (declaration of 'o.pv' appears in /data/app/~~5uAI-TWpCWRT1xO82JB8JQ==/com.malin.hook-UHkYGi3lVHfz3o-kYCKHhQ==/base.apk)
210+
at com.malin.plugin.BaseActivity.onCreate(SourceFile:20)
211+
at com.malin.plugin.PluginAppCompatActivity.onCreate(SourceFile:17)
212+
at android.app.Activity.performCreate(Activity.java:8054)
213+
at android.app.Activity.performCreate(Activity.java:8034)
214+
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341)
215+
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3688)
216+
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3864)
217+
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
218+
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
219+
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
220+
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)
221+
at android.os.Handler.dispatchMessage(Handler.java:106)
222+
at android.os.Looper.loopOnce(Looper.java:201)
223+
at android.os.Looper.loop(Looper.java:288)
224+
at android.app.ActivityThread.main(ActivityThread.java:7870)
225+
at java.lang.reflect.Method.invoke(Native Method)
226+
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
227+
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

pluginapk/.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
/build
2-
proguard-merge-config.txt
2+
.classpath
3+
.project
4+
.settings
5+
proguard-merge-config.txt
6+
mapping.txt

pluginapk/build.gradle.kts

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
plugins {
44
id("com.android.application")
5+
id("project-report")
6+
id("com.guardsquare.proguard")
7+
kotlin("android")
58
}
69

710
android {
@@ -18,13 +21,43 @@ android {
1821
versionName = AppConfig.versionName
1922
}
2023

24+
signingConfigs {
25+
getByName("debug") {
26+
enableV1Signing = true
27+
enableV2Signing = true
28+
enableV3Signing = true
29+
enableV4Signing = true
30+
}
31+
create("release") {
32+
enableV1Signing = true
33+
enableV2Signing = true
34+
keyAlias = "plugin"
35+
keyPassword = "plugin"
36+
storeFile = file("../plugin.jks")
37+
storePassword = "plugin"
38+
}
39+
}
40+
41+
packagingOptions {
42+
resources.excludes += "META-INF/*"
43+
resources.excludes += "META-INF/CERT.SF"
44+
resources.excludes += "META-INF/CERT.RSA"
45+
resources.excludes += "META-INF/MANIFEST.MF"
46+
}
47+
2148
buildTypes {
49+
getByName("debug") {
50+
isDebuggable = true
51+
isCrunchPngs = false
52+
isMinifyEnabled = false
53+
isShrinkResources = false
54+
signingConfig = signingConfigs.getByName("debug")
55+
}
2256
getByName("release") {
57+
// https://www.guardsquare.com/manual/setup/upgrading
2358
isMinifyEnabled = false
24-
proguardFiles(
25-
getDefaultProguardFile("proguard-android-optimize.txt"),
26-
"proguard-rules.pro"
27-
)
59+
isShrinkResources = false
60+
signingConfig = signingConfigs.getByName("release")
2861
}
2962
}
3063
compileOptions {
@@ -33,6 +66,16 @@ android {
3366
}
3467
}
3568

69+
// https://www.guardsquare.com/manual/setup/upgrading
70+
proguard {
71+
configurations {
72+
register("release") {
73+
defaultConfiguration("proguard-android-optimize.txt")
74+
configuration("proguard-rules.pro")
75+
}
76+
}
77+
}
78+
3679
dependencies {
3780
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
3881
implementation(DependenciesConfig.APP_COMPAT)

0 commit comments

Comments
 (0)