You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,11 +96,52 @@ android {
96
96
}
97
97
```
98
98
99
+
## Access inside Kotlin
100
+
99
101
Access your secret key by calling :
100
102
```kotlin
101
103
val key =MainSecrets().getYourSecretKeyName()
102
104
```
103
105
106
+
## Access inside Java
107
+
108
+
The names of the methods in the generated files (`MainSecrets.kt` & `Secrets.kt`) are replaced with dummy strings such as `a0` on the `JVM` side for extra security. This makes accessing these methods inside `Java` classes a bit tricky since those names are not "readable" and are dependent on the order in `secrets.json` file.
109
+
110
+
As as solution, a helper/wrapper `Kotlin` class can be created instead of accessing these methods directly inside a `Java` class:
111
+
112
+
`MySecretsHelper.kt`:
113
+
```kotlin
114
+
internalclassMySecretsHelper {
115
+
val secrets =MainSecrets() // Suppose contains "external fun getYourSecretKeyName(): String" with "@JvmName("a0")" annotation.
116
+
val mySecret:String get() = secrets.getYourSecretKeyName()
If you are working on multi-flavor projects and have flavor-specific secrets, you need to pass arguments to CMake in your `build.gradle[.kts]` file. Follow the steps below:
0 commit comments