Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add android docs #547

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
java-version: '21'
- uses: subosito/flutter-action@v2
with:
channel: "stable"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5.2.0
- uses: amannn/action-semantic-pull-request@v5.4.0
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
37 changes: 27 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,37 @@ jobs:
with:
channel: 'stable'
- name: Build iOS App
run: cd example && flutter build ios --debug --no-codesign
run: |
dart pub global activate melos
melos bootstrap
cd example && flutter build ios --debug --no-codesign
- name: Run native iOS tests
run: cd example/ios && xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12,OS=16.2' test
run: |
dart pub global activate melos
melos bootstrap
cd example/ios && xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12,OS=16.2' test

native_android_tests:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
java-version: '21'
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
- name: Build Android App
run: cd example && flutter build apk --debug
run: |
dart pub global activate melos
melos bootstrap
cd example && flutter build apk --debug
- name: Run native Android tests
run: cd example/android && gradle workmanager:test
run: |
dart pub global activate melos
melos bootstrap
cd example/android && gradle workmanager:test

drive_ios:
strategy:
Expand All @@ -55,7 +68,7 @@ jobs:
fail-fast: false
runs-on: macos-latest
steps:
- uses: futureware-tech/simulator-action@v1
- uses: futureware-tech/simulator-action@v3
with:
model: '${{ matrix.device }}'
- uses: actions/checkout@v4
Expand All @@ -64,7 +77,10 @@ jobs:
channel: 'stable'
# Run flutter integrate tests
- name: Run Flutter integration tests
run: cd example && flutter test integration_test/workmanager_integration_test.dart
run: |
dart pub global activate melos
melos bootstrap
cd example && flutter test integration_test/workmanager_integration_test.dart


drive_android:
Expand All @@ -78,9 +94,10 @@ jobs:
target: [default]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
java-version: '21'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
Expand Down
24 changes: 24 additions & 0 deletions docs/android.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Check your AndroidManifest.xml

Check if you have the following in your `AndroidManifest.xml` file.

```xml
<meta-data
android:name="flutterEmbedding"
android:value="2" />
```

Ideally you should have this, if not follow the [upgrade guide](https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects).
If for some reason you can't upgrade yet we still support the [older way of embedding](ANDROID_SETUP_V1.md):

# How to Debug my background job

Debugging a background task can be difficult, Android decides when is the best time to run.
There is no guaranteed way to enforce a run of a job even in debug mode.

However to facilitate debugging, the plugin provides an `isInDebugMode` flag when initializing the plugin: `Workmanager().initialize(callbackDispatcher, isInDebugMode: true)`

Once this flag is enabled you will receive a notification whenever a background task was triggered.
This way you can keep track whether that task ran successfully or not.

<img src=".art/android_debug_notification.gif" height="650">
Loading