Skip to content

Commit 876a8f9

Browse files
committed
docs: add internal usage attribution disable instructions and secrets setup
1 parent cdb28ce commit 876a8f9

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,26 @@ This repository includes a [sample app](demo) that illustrates the use of this l
6161

6262
To run the demo app, ensure you've met the requirements above then:
6363
1. Clone the repository
64-
1. Add a file `local.properties` in the root project (this file should *NOT* be under version control to protect your API key)
65-
1. Add a single line to `local.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained earlier
64+
1. Add a file `secrets.properties` in the root project (this file should *NOT* be under version control to protect your API key)
65+
1. Add the following keys to `secrets.properties`:
66+
- `MAPS_API_KEY`: **Required**. Your Google Maps API Key. Ensure it has the **Maps SDK for Android** enabled.
67+
- `PLACES_API_KEY`: **Optional**. Required for demos using the Places API (e.g., Heatmaps with Places). Ensure the **Places API** is enabled.
68+
- `MAP_ID`: **Optional**. Required for demos using Advanced Markers or Cloud-based Map Styling.
69+
70+
For example:
71+
```properties
72+
MAPS_API_KEY=YOUR_MAPS_API_KEY
73+
PLACES_API_KEY=YOUR_PLACES_API_KEY
74+
MAP_ID=YOUR_MAP_ID
75+
```
6676
1. Build and run the `debug` variant for the Maps SDK for Android version
6777

6878
### Setting up the Map ID
6979

7080
Some of the features in the demo app, such as Advanced Markers, require a Map ID. You can learn more about map IDs in the [official documentation](https://developers.google.com/maps/documentation/android-sdk/map-ids/mapid-over). You can set the Map ID in one of the following ways:
7181

7282
1. **`secrets.properties`:** Add a line to your `secrets.properties` file with your Map ID:
73-
```
83+
```properties
7484
MAP_ID=YOUR_MAP_ID
7585
```
7686

@@ -144,6 +154,24 @@ By default, the `Source` is set to `Source.DEFAULT`, but you can also specify `S
144154

145155
</details>
146156

157+
## Internal usage attribution ID
158+
159+
This library calls the `addInternalUsageAttributionId` method, which helps Google understand which libraries and samples are helpful to developers and is optional. Instructions for opting out of the identifier are provided below.
160+
161+
If you wish to disable this, you can do so by removing the initializer in your `AndroidManifest.xml` using the `tools:node="remove"` attribute:
162+
163+
```xml
164+
<provider
165+
android:name="androidx.startup.InitializationProvider"
166+
android:authorities="${applicationId}.androidx-startup"
167+
android:exported="false"
168+
tools:node="merge">
169+
<meta-data
170+
android:name="com.google.maps.android.utils.attribution.AttributionIdInitializer"
171+
tools:node="remove" />
172+
</provider>
173+
```
174+
147175
## Contributing
148176

149177
Contributions are welcome and encouraged! If you'd like to contribute, send us a [pull request] and refer to our [code of conduct] and [contributing guide].

library/src/main/java/com/google/maps/android/utils/attribution/AttributionIdInitializer.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ import com.google.android.gms.maps.MapsApiSettings
2222
import com.google.maps.android.utils.meta.AttributionId
2323

2424
/**
25-
* Initializes the AttributionId at application startup.
25+
* Adds a usage attribution ID to the initializer, which helps Google understand which libraries and samples are helpful to developers, such as usage of this library.
26+
* To opt out of sending the usage attribution ID, please remove this initializer from your manifest.
2627
*/
2728
internal class AttributionIdInitializer : Initializer<Unit> {
2829
override fun create(context: Context) {
30+
// See [AttributionIdInitializer]
2931
MapsApiSettings.addInternalUsageAttributionId(
3032
/* context = */ context,
3133
/* internalUsageAttributionId = */ AttributionId.VALUE

0 commit comments

Comments
 (0)