Skip to content

Commit 8bc18e3

Browse files
Merge pull request #102 from Web3Auth/feat/proguard_rules_optimiations
Feat/proguard rules optimizations
2 parents 4b56667 + 818c1c4 commit 8bc18e3

File tree

4 files changed

+115
-16
lines changed

4 files changed

+115
-16
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ android {
5151
dependencies {
5252
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
5353
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
54-
implementation 'com.github.Web3Auth:web3auth-android-sdk:9.1.2'
54+
implementation 'com.github.Web3Auth:web3auth-android-sdk:9.1.3'
5555
implementation 'com.google.code.gson:gson:2.10.1'
5656
}

android/consumer_rules.pro

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Keep Kotlin metadata
2+
-keepclassmembers class ** {
3+
@kotlin.Metadata *;
4+
}
5+
6+
# Keep public classes and members of your SDK
7+
-keep class com.web3auth.** { *; }
8+
9+
# If using Gson (for JSON parsing)
10+
-keep class com.google.gson.** { *; }
11+
-keepattributes *Annotation*
12+
-keepclassmembers class * {
13+
@com.google.gson.annotations.SerializedName <fields>;
14+
}
15+
16+
# Keep method names and constructor params
17+
-keepattributes Signature, InnerClasses, EnclosingMethod, *Annotation*, SourceFile, LineNumberTable
18+
19+
# If you use coroutines or lambdas
20+
-keep class kotlinx.coroutines.** { *; }
21+
-dontwarn kotlinx.coroutines.**
22+
23+
# To avoid stripping methods like getError(), setCustomTabsClosed(), etc.
24+
-keepclassmembers class ** {
25+
*** getError(...);
26+
void setCustomTabsClosed(...);
27+
}
28+
29+
# Preserve Kotlin metadata and parameter names
30+
-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod
31+
-keep class kotlin.Metadata { *; }
32+
-keepclassmembers class ** {
33+
@kotlin.Metadata *;
34+
}
35+
36+
# Optional: Keep your SDK class and its methods fully
37+
-keep class com.web3auth.flutter.web3auth_flutter.Web3AuthFlutterPlugin {
38+
*;
39+
}
40+
41+
-keepclassmembers class com.web3auth.core.Web3Auth {
42+
public static <methods>;
43+
}
44+
45+
# Preserve the entire Kotlin object class (prevents it from being removed/renamed)
46+
-keep class com.web3auth.core.types.Web3AuthError {
47+
*;
48+
}

android/proguard-rules.pro

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Keep Kotlin metadata
2+
-keepclassmembers class ** {
3+
@kotlin.Metadata *;
4+
}
5+
6+
# Keep public classes and members of your SDK
7+
-keep class com.web3auth.** { *; }
8+
9+
# If using Gson (for JSON parsing)
10+
-keep class com.google.gson.** { *; }
11+
-keepattributes *Annotation*
12+
-keepclassmembers class * {
13+
@com.google.gson.annotations.SerializedName <fields>;
14+
}
15+
16+
# Keep method names and constructor params
17+
-keepattributes Signature, InnerClasses, EnclosingMethod, *Annotation*, SourceFile, LineNumberTable
18+
19+
# If you use coroutines or lambdas
20+
-keep class kotlinx.coroutines.** { *; }
21+
-dontwarn kotlinx.coroutines.**
22+
23+
# To avoid stripping methods like getError(), setCustomTabsClosed(), etc.
24+
-keepclassmembers class ** {
25+
*** getError(...);
26+
void setCustomTabsClosed(...);
27+
}
28+
29+
# Preserve Kotlin metadata and parameter names
30+
-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod
31+
-keep class kotlin.Metadata { *; }
32+
-keepclassmembers class ** {
33+
@kotlin.Metadata *;
34+
}
35+
36+
# Optional: Keep your SDK class and its methods fully
37+
-keep class com.web3auth.flutter.web3auth_flutter.Web3AuthFlutterPlugin {
38+
*;
39+
}
40+
41+
-keepclassmembers class com.web3auth.core.Web3Auth {
42+
public static <methods>;
43+
}
44+
45+
# Preserve the entire Kotlin object class (prevents it from being removed/renamed)
46+
-keep class com.web3auth.core.types.Web3AuthError {
47+
*;
48+
}

android/src/main/kotlin/com/web3auth/flutter/web3auth_flutter/Web3AuthFlutterPlugin.kt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.Context
55
import android.content.Intent
66
import android.net.Uri
77
import android.util.Log
8+
import androidx.annotation.Keep
89
import androidx.annotation.NonNull
910
import com.google.gson.Gson
1011
import com.google.gson.JsonArray
@@ -29,7 +30,6 @@ import kotlinx.coroutines.Dispatchers
2930
import kotlinx.coroutines.launch
3031
import org.json.JSONObject
3132

32-
3333
class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
3434
PluginRegistry.NewIntentListener {
3535
private lateinit var channel: MethodChannel
@@ -196,8 +196,8 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
196196
val wsParams = gson.fromJson(wsArgs, WalletServicesJson::class.java)
197197
Log.d(wsParams.toString(), "#wsParams")
198198
val launchWalletCF = web3auth.launchWalletServices(
199-
chainConfig = wsParams.chainConfig,
200-
path = wsParams.path
199+
wsParams.chainConfig,
200+
wsParams.path
201201
)
202202
launchWalletCF.get()
203203
return null
@@ -246,11 +246,11 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
246246
val reqParams = gson.fromJson(requestArgs, RequestJson::class.java)
247247
Log.d(reqParams.toString(), "#reqParams")
248248
val requestCF = web3auth.request(
249-
chainConfig = reqParams.chainConfig,
250-
method = reqParams.method,
251-
requestParams = convertListToJsonArray(reqParams.requestParams) ,
252-
path = reqParams.path,
253-
appState = reqParams.appState
249+
reqParams.chainConfig,
250+
reqParams.method,
251+
convertListToJsonArray(reqParams.requestParams) ,
252+
reqParams.path,
253+
reqParams.appState
254254
)
255255
return gson.toJson(requestCF.get())
256256
} catch (e: NotImplementedError) {
@@ -299,14 +299,17 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
299299
return jsonArray
300300
}
301301
}
302+
@Keep
302303
data class WalletServicesJson(
303-
val chainConfig: ChainConfig,
304-
val path: String? = "wallet"
304+
@Keep val chainConfig: ChainConfig,
305+
@Keep val path: String? = "wallet"
305306
)
307+
308+
@Keep
306309
data class RequestJson(
307-
val chainConfig: ChainConfig,
308-
val method: String,
309-
val requestParams: List<Any?>,
310-
val path: String? = "wallet/request",
311-
val appState: String? = null
310+
@Keep val chainConfig: ChainConfig,
311+
@Keep val method: String,
312+
@Keep val requestParams: List<Any?>,
313+
@Keep val path: String? = "wallet/request",
314+
@Keep val appState: String? = null
312315
)

0 commit comments

Comments
 (0)