Skip to content

Commit 9926cf3

Browse files
committed
Improve androidmanifest code examples
1 parent 79e2c76 commit 9926cf3

File tree

1 file changed

+76
-20
lines changed

1 file changed

+76
-20
lines changed

docs/ff-concepts/adding-customization/configuration-files.md

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ For more complex changes, you can enable **Manual Edit Mode**, which essentially
114114

115115
To manually edit native files, navigate to **Custom Code** (from the left-side menu) > **Configuration Files**, select the file you want to edit, and click the **lock** button to unlock it. You can now freely modify the file.
116116

117-
:::tip
118-
Once unlocked, the file stays in manual editing mode until you lock it again. Locking it will reset the file to a version generated by FlutterFlow.
117+
:::warning
118+
Once unlocked, the file stays in manual editing mode until you lock it again. Re-locking it will reset the file to a version generated by FlutterFlow, which will overwrite any manual changes you've made.
119119
:::
120120

121121
<div style={{
@@ -226,7 +226,19 @@ Here are some scenarios where you may need to modify the `AndroidManifest.xml` f
226226
For including additional screens (activities), background processes (services), or listeners (broadcast receivers), you must declare them in `AndroidManifest.xml`.
227227

228228
```xml
229-
<activity android:name=".NewScreenActivity"/>
229+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
230+
package="com.example.app">
231+
232+
<application
233+
android:icon="@mipmap/ic_launcher"
234+
android:label="@string/app_name">
235+
236+
<!-- Add your activity here -->
237+
<activity android:name=".NewScreenActivity" />
238+
239+
</application>
240+
241+
</manifest>
230242
```
231243

232244
This registers `NewScreenActivity` so the system knows it exists.
@@ -236,8 +248,23 @@ This registers `NewScreenActivity` so the system knows it exists.
236248
If your app requires access to restricted resources like wake locks (to keep the device awake) or audio recording, you must declare the necessary permissions in `AndroidManifest.xml` by [manually editing](#option-2-manual-edit-mode) the file. **Tip:** You can also add custom permissions directly through the [**Permission Settings**](../../resources/projects/settings/project-setup.md#adding-custom-permission) in FlutterFlow.
237249

238250
```xml
239-
<uses-permission android:name="android.permission.WAKE_LOCK"/>
240-
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
251+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
252+
package="com.example.yourappname">
253+
254+
<!-- Permissions -->
255+
<uses-permission android:name="android.permission.WAKE_LOCK"/>
256+
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
257+
258+
<application
259+
android:label=""
260+
tools:replace="android:label"
261+
android:icon="@mipmap/ic_launcher"
262+
android:requestLegacyExternalStorage="true">
263+
264+
<activity android:name=".NewScreenActivity"/>
265+
266+
</application>
267+
</manifest>
241268
```
242269

243270
Without these, the app cannot keep the device awake or record audio.
@@ -247,37 +274,66 @@ Without these, the app cannot keep the device awake or record audio.
247274
Many third-party packages (Google Maps, Firebase, AdMob, etc.) require `<meta-data>` tag in `AndroidManifest.xml` to pass configuration values. For example, the [**Mapbox Flutter**](https://pub.dev/packages/mapbox_flutter) plugin requires adding your Mapbox access token as a metadata entry for initialization. A real example: to initialize Mapbox, you’d add:
248275

249276
```xml
250-
<meta-data
251-
android:name="com.mapbox.token"
252-
android:value="YOUR_MAPBOX_ACCESS_TOKEN"/>
253-
```
277+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
278+
package="com.example.app">
254279

255-
**Example 4: Configuring Play Asset Delivery**
280+
<application
281+
android:icon="@mipmap/ic_launcher"
282+
android:label="@string/app_name">
256283

257-
If your app has large assets (e.g., high-resolution textures, large media files), you may need Play Asset Delivery.
284+
<!-- Your snippet goes here -->
285+
<meta-data
286+
android:name="com.example.MAPS_API_KEY"
287+
android:value="YOUR_API_KEY" />
258288

259-
```xml
260-
<meta-data
261-
android:name="com.google.android.play.assetdelivery"
262-
android:value="install-time"/>
289+
</application>
290+
</manifest>
263291
```
264292

265-
This tells Google Play how to handle large assets.
266-
267-
**Example 5: Restricting the App to Specific Devices**
293+
**Example 4: Restricting the App to Specific Devices**
268294

269295
You can specify device hardware requirements (e.g., GPS, camera, touchscreen) to ensure the app only installs on compatible devices.
270296

271297
```xml
272-
<uses-feature android:name="android.hardware.camera" android:required="true"/>
298+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
299+
package="com.example.app">
300+
301+
<!-- Your snippet goes here -->
302+
<uses-feature android:name="android.hardware.camera" />
303+
304+
<application
305+
android:icon="@mipmap/ic_launcher"
306+
android:label="@string/app_name">
307+
308+
<!-- other components -->
309+
310+
</application>
311+
312+
</manifest>
273313
```
274314

275315
This prevents installation on devices without a camera.
276316

277-
**Example 6: Enabling Cleartext Traffic**
317+
**Example 5: Enabling Cleartext Traffic**
278318

279319
If your app needs to communicate over HTTP (unencrypted) for testing or legacy reasons, you might need to add `android:usesCleartextTraffic="true"` in the `<application>` tag. This is to relax network security for HTTP URLs.
280320

321+
```xml
322+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
323+
package="com.example.app">
324+
325+
<application
326+
android:icon="@mipmap/ic_launcher"
327+
android:label="@string/app_name"
328+
android:usesCleartextTraffic="true"> <!-- Add this line -->
329+
330+
<!-- Other components -->
331+
332+
</application>
333+
334+
</manifest>
335+
```
336+
281337
:::tip
282338
You can modify the `AndroidManifest.xml` file by either [**adding a snippet**](#snippet-placement-for-android) or [**editing it manually**](#option-2-manual-edit-mode).
283339
:::

0 commit comments

Comments
 (0)