Skip to content

Commit 7f0ed97

Browse files
committed
refact: 更新 RePluginX 版本;更新 demo1 依赖
1 parent 82fdf37 commit 7f0ed97

File tree

4 files changed

+217
-10
lines changed

4 files changed

+217
-10
lines changed

proguard-rules-android.pro

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
23+
#############################################
24+
#
25+
# 对于一些基本指令的添加
26+
#
27+
#############################################
28+
# 代码混淆压缩比,在0~7之间,默认为5,一般不做修改
29+
-optimizationpasses 5
30+
31+
# 混合时不使用大小写混合,混合后的类名为小写
32+
-dontusemixedcaseclassnames
33+
34+
# 指定不去忽略非公共库的类
35+
-dontskipnonpubliclibraryclasses
36+
37+
# 这句话能够使我们的项目混淆后产生映射文件
38+
# 包含有类名->混淆后类名的映射关系
39+
-verbose
40+
41+
# 指定不去忽略非公共库的类成员
42+
-dontskipnonpubliclibraryclassmembers
43+
44+
# 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。
45+
-dontpreverify
46+
47+
# 保留Annotation不混淆
48+
-keepattributes *Annotation*,InnerClasses
49+
50+
# 避免混淆泛型
51+
-keepattributes Signature
52+
53+
# 抛出异常时保留代码行号
54+
-keepattributes SourceFile,LineNumberTable
55+
56+
# 指定混淆是采用的算法,后面的参数是一个过滤器
57+
# 这个过滤器是谷歌推荐的算法,一般不做更改
58+
-optimizations !code/simplification/cast,!field/*,!class/merging/*
59+
60+
61+
#############################################
62+
#
63+
# Android开发中一些需要保留的公共部分
64+
#
65+
#############################################
66+
# 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
67+
# 因为这些子类都有可能被外部调用
68+
-keep public class * extends android.app.Activity
69+
-keep public class * extends android.app.Appliction
70+
-keep public class * extends android.app.Service
71+
-keep public class * extends android.content.BroadcastReceiver
72+
-keep public class * extends android.content.ContentProvider
73+
-keep public class * extends android.app.backup.BackupAgentHelper
74+
-keep public class * extends android.preference.Preference
75+
-keep public class * extends android.view.View
76+
-keep public class com.android.vending.licensing.ILicensingService
77+
78+
79+
# 保留support下的所有类及其内部类
80+
-keep class android.support.** {*;}
81+
82+
# 保留继承的
83+
-keep public class * extends android.support.v4.**
84+
-keep public class * extends android.support.v7.**
85+
-keep public class * extends android.support.annotation.**
86+
87+
# 保留R下面的资源
88+
-keep class **.R$* {*;}
89+
90+
# 保留本地native方法不被混淆
91+
-keepclasseswithmembernames class * {
92+
native <methods>;
93+
}
94+
95+
# 保留在Activity中的方法参数是view的方法,
96+
# 这样以来我们在layout中写的onClick就不会被影响
97+
-keepclassmembers class * extends android.app.Activity{
98+
public void *(android.view.View);
99+
}
100+
101+
# 保留枚举类不被混淆
102+
-keepclassmembers enum * {
103+
public static **[] values();
104+
public static ** valueOf(java.lang.String);
105+
}
106+
107+
# 保留我们自定义控件(继承自View)不被混淆
108+
-keep public class * extends android.view.View{
109+
*** get*();
110+
void set*(***);
111+
public <init>(android.content.Context);
112+
public <init>(android.content.Context, android.util.AttributeSet);
113+
public <init>(android.content.Context, android.util.AttributeSet, int);
114+
}
115+
116+
# 保留Parcelable序列化类不被混淆
117+
-keep class * implements android.os.Parcelable {
118+
public static final android.os.Parcelable$Creator *;
119+
}
120+
121+
# 保留Serializable序列化的类不被混淆
122+
-keepclassmembers class * implements java.io.Serializable {
123+
static final long serialVersionUID;
124+
private static final java.io.ObjectStreamField[] serialPersistentFields;
125+
!static !transient <fields>;
126+
!private <fields>;
127+
!private <methods>;
128+
private void writeObject(java.io.ObjectOutputStream);
129+
private void readObject(java.io.ObjectInputStream);
130+
java.lang.Object writeReplace();
131+
java.lang.Object readResolve();
132+
}
133+
134+
# 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
135+
-keepclassmembers class * {
136+
void *(**On*Event);
137+
void *(**On*Listener);
138+
}
139+
140+
# webView处理,项目中没有使用到webView忽略即可
141+
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
142+
public *;
143+
}
144+
-keepclassmembers class * extends android.webkit.webViewClient {
145+
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
146+
public boolean *(android.webkit.WebView, java.lang.String);
147+
}
148+
-keepclassmembers class * extends android.webkit.webViewClient {
149+
public void *(android.webkit.webView, jav.lang.String);
150+
}
151+
152+
# AndroidX
153+
-keep class com.google.android.material.** {*;}
154+
-keep class androidx.** {*;}
155+
-keep public class * extends androidx.**
156+
-keep interface androidx.** {*;}
157+
-dontwarn com.google.android.material.**
158+
-dontnote com.google.android.material.**
159+
-dontwarn androidx.**
160+
161+
# databinding
162+
-dontwarn android.databinding.**
163+
-keep class android.databinding.** { *; }
164+
165+
#############################################
166+
#
167+
# 运行错误
168+
#
169+
#############################################
170+
#-keep class okhttp3.** { *; }
171+
#-keep interface okhttp3.** { *; }
172+
#-dontwarn okhttp3.**
173+
#
174+
#-keep class okio.** { *; }
175+
#-keep interface okio.** { *; }
176+
#-dontwarn okio.**
177+
178+
-keep class com.hitomi.** { *; }
179+
-keep interface com.hitomi.** { *; }
180+
-dontwarn com.hitomi.**
181+
182+
183+
# 保留源文件名及行号
184+
-keepattributes SourceFile,LineNumberTable
185+
-ignorewarnings
186+
187+
# 解决Tinker补丁合并成功,重启闪退问题
188+
-dontoptimize
189+
190+
# 保留 java sdk
191+
-keep class java.lang.** {*;}

repluginx-sample/plugin/plugin-demo1/app/build.gradle

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ android {
3535
}
3636

3737
buildTypes {
38-
release {
38+
debug {
3939
minifyEnabled false
40+
shrinkResources false
41+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
42+
}
43+
release {
44+
minifyEnabled true
45+
shrinkResources true
4046
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4147
}
4248
}
@@ -61,6 +67,9 @@ repositories {
6167
apply plugin: 'replugin-plugin-gradle'
6268
repluginPluginConfig {
6369
// enable = true // 是否启用插件功能,默认为true
70+
classExcludes = ["androidx.*"]
71+
// classExcludes = ["com.qihoo360.replugin.sample.demo1.*"]
72+
// classIncludes = ["com.qihoo360.replugin.sample.demo1.BaseActivity"]
6473
pluginName = "demo1"
6574
hostApplicationId = "com.qihoo360.replugin.sample.host"
6675
hostAppLauncherActivity = "com.qihoo360.replugin.sample.host.MainActivity"
@@ -79,14 +88,16 @@ dependencies {
7988
// https://github.com/luohaoxuan320/RePluginDemo/wiki/%E6%8F%92%E4%BB%B6-AppCompatActivity-%E4%B8%8E-v4.Fragment%E5%85%B1%E5%AD%98
8089
// compileOnly dependenciesExt['appcompat-androidx']
8190

82-
// 这个jar就是从Androidx-fragment中提取出来的并非特制包目的是为了骗过编译期
83-
compileOnly files('libs/androidx-fragment.jar')
84-
// androidx-fragment 需要依赖的其他jar包 begin ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
85-
compileOnly files('libs/androidx-lifecycle-common-2.4.0.jar')
86-
compileOnly files('libs/androidx-lifecycle-viewmodel.jar')
87-
compileOnly files('libs/androidx-activity.jar')
88-
compileOnly files('libs/androidx-savedstate.jar')
89-
// androidx-fragment 需要依赖的其他jar包 end ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
91+
// 注:有 classExcludes 之后,不再使用这种方式,直接 implementation 第三方库即可!!
92+
// // 这个jar就是从Androidx-fragment中提取出来的并非特制包目的是为了骗过编译期
93+
// compileOnly files('libs/androidx-fragment.jar')
94+
// // androidx-fragment 需要依赖的其他jar包 begin ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
95+
// compileOnly files('libs/androidx-lifecycle-common-2.4.0.jar')
96+
// compileOnly files('libs/androidx-lifecycle-viewmodel.jar')
97+
// compileOnly files('libs/androidx-activity.jar')
98+
// compileOnly files('libs/androidx-savedstate.jar')
99+
// // androidx-fragment 需要依赖的其他jar包 end ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
100+
implementation dependenciesExt['appcompat-androidx']
90101

91102
compileOnly files('libs/common-utils-lib-1.0.0.jar') //这 个jar就是从Host的utils中编译生成的,其目的是为了骗过编译期
92103

repluginx-sample/plugin/plugin-demo1/app/proguard-rules.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
# public *;
1717
#}
1818

19+
-include ../../../../proguard-rules-android.pro
20+
21+
-keepclasseswithmembers class com.qihoo360.replugin.sample.demo1.** {
22+
}
23+
1924
# ---------------------------------------------
2025
# **不要改动**
2126
# 插件框架、崩溃后台等需要

rpx-config.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ project.ext {
2020
// AGP版本号,AndroidX 至少 3.2.0 起步;基于3.2.1,为了兼容低版本 AGP
2121
android_build_tools_version = "3.2.1" // 4.1.1,3.5.3,3.2.1,2.3.3,
2222
kotlin_version = '1.2.51' // 1.1.3
23-
repluginx_version = 'v0.0.6'
23+
repluginx_version = 'v0.0.7'
2424
support_version = '28.0.0'
2525
androidx_version = '1.2.0'
2626

0 commit comments

Comments
 (0)