Skip to content

Commit 2b616dd

Browse files
authored
Removed preguarding of the SDKs. (#44)
* Removed preguarding of the SDKs. * Removed the preguard configs.
1 parent 8982700 commit 2b616dd

File tree

7 files changed

+23
-163
lines changed

7 files changed

+23
-163
lines changed

README.md

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ https://firebase.google.com.
2121
1. [Unit Testing](#unit-testing)
2222
1. [Integration Testing](#integration-testing)
2323
1. [Proguarding](#proguarding)
24-
1. [APIs used via reflection](#apis-used-via-reflection)
24+
1. [APIs used via reflection](#APIs-used-via-reflection)
2525
1. [APIs intended for developer
26-
consumption](#apis-intended-for-developer-consumption)
26+
consumption](#APIs-intended-for-developer-consumption)
2727
1. [APIs intended for other Firebase
28-
SDKs](#apis-intended-for-other-firebase-sdks)
28+
SDKs](#APIs-intended-for-other-firebase-sdks)
2929
1. [Publishing](#publishing)
3030
1. [Dependencies](#dependencies)
3131
1. [Commands](#commands)
@@ -87,70 +87,47 @@ If you don't have a suitable testing project already:
8787
* Download the resulting `google-services.json` file and put it in the root of
8888
your checkout.
8989

90-
For now, you have to disable security rule enforcement for the Realtime
91-
Database, Cloud Firestore, and Cloud Storage in your test project (if running
92-
the integration tests for any of those). Re-enable your security rules after
93-
your test run.
94-
9590
#### Running Integration Tests
9691

9792
Integration tests can be executed on the command line by running
9893
```bash
9994
./gradlew :<firebase-project>:connectedCheck
10095
```
10196

102-
## Proguarding
97+
## Annotations
10398

104-
Firebase Android SDKs operate under the assumption that a vast majority of
105-
developers do not proguard their apps. Artifacts published via the
106-
[Publishing](#publishing) section are pre-proguarded (preguarded?) to reduce the
107-
size impact on apps that consume them. There are three levels of retention that
108-
APIs have, depending on how they are used.
99+
Firebase SDKs use some special annotations for tooling purposes.
109100

110-
### APIs used via reflection
101+
### @Keep
111102

112103
APIs that need to be preserved up until the app's runtime can be annotated with
113104
[@Keep](https://developer.android.com/reference/android/support/annotation/Keep).
114105
The
115106
[@Keep](https://developer.android.com/reference/android/support/annotation/Keep)
116107
annotation is *blessed* to be honored by android's [default proguard
117-
configuration](https://developer.android.com/studio/write/annotations#keep).
118-
These APIs should be generally **discouraged**, because they can't be
119-
proguarded.
120-
121-
#### Usage
122-
123-
- Annotate APIs with
124-
[@Keep](https://developer.android.com/reference/android/support/annotation/Keep)
108+
configuration](https://developer.android.com/studio/write/annotations#keep). A common use for
109+
this annotation is because of reflection. These APIs should be generally **discouraged**, because
110+
they can't be proguarded.
125111

126-
### APIs intended for developer consumption
127-
128-
The
129-
[@Keep](https://developer.android.com/reference/android/support/annotation/Keep)
130-
mechanism described above is too restrictive for APIs that are not used via
131-
reflection, which is the case for a vast majority of the Firebase public APIs.
132-
We annotate these APIs with
133-
[@PublicAPI](firebase-common/src/main/java/com/google/firebase/annotations/PublicApi.java).
112+
### @KeepForSdk
134113

135-
#### Usage
114+
APIs that are intended to be used by Firebase SDKs should be annotated with
115+
`@KeepForSdk`. The key benefit here is that the annotation is *blessed* to throw
116+
linter errors on Android Studio if used by the developer from a non firebase
117+
package, thereby providing a valuable guard rail.
136118

137-
- Annotate the necessary APIs with firebase-common's
138-
[@PublicApi](firebase-common/src/main/java/com/google/firebase/annotations/PublicApi.java)
139119

140-
### APIs intended for other Firebase SDKs
120+
### @PublicApi
141121

142-
APIs that are intended to be used by Firebase SDKs may be annotated with
143-
`@KeepForSdk`. Much like the custom annotation mechanism, the idea is to let
144-
these APIs pass through preguarding, but not restrict the developer's app from
145-
proguarding. The key benefit here is that the annotation is *blessed* to throw
146-
linter errors on Android Studio if used by the developer from a non firebase
147-
package, thereby providing a valuable guard rail.
122+
We annotate APIs that meant to be used by developers with
123+
[@PublicAPI](firebase-common/src/main/java/com/google/firebase/annotations/PublicApi.java). This
124+
annotation will be used by tooling to help inform the version bump (major, minor, patch) that is
125+
required for the next release.
148126

149-
#### Usage
127+
## Proguarding
150128

151-
- Annotate the APIs with `@KeepForSdk`
152-
- This method may be used in conjunction with @Keep annotations to annotate APIs
153-
consumed by Firebase SDKs through reflection.
129+
Firebase SDKs do not proguard themselves, but support proguarding. Firebase SDKs themselves are
130+
proguard friendly, but the dependencies of Firebase SDKs may not be.
154131

155132
### Proguard config
156133

@@ -209,9 +186,6 @@ projects may be published as follows.
209186
publishProjectsToMavenLocal
210187
```
211188

212-
To generate the Maven dependency tree under `build/` instead, you can replace
213-
`publishProjectsToMavenLocal` in the above command with `firebasePublish`.
214-
215189
### Code Formatting
216190

217191
Code in this repo is formatted with the google-java-format tool. You can enable

firebase-common/preguard.txt

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

firebase-database/preguard.txt

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

firebase-firestore/preguard.txt

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

firebase-functions/preguard.txt

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

firebase-storage/preguard.txt

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

root-project.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ configure(subprojects) {
126126
// Apply the retrolambda plugin
127127
sub.apply plugin: 'me.tatarka.retrolambda'
128128

129-
boolean skipPreguard = sub.getProperties().getOrDefault('firebaseSkipPreguard', 'false').toBoolean()
129+
boolean skipPreguard = sub.getProperties().getOrDefault('firebaseSkipPreguard', 'true').toBoolean()
130130
def defaultPreguard = rootProject.getProperties().getOrDefault('firebaseDefaultPreguardFile', 'default-preguard.txt')
131131

132132
if(!skipPreguard) {

0 commit comments

Comments
 (0)