-
Notifications
You must be signed in to change notification settings - Fork 537
Build Android app before turning on emulator on Android #1464
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
Conversation
@@ -76,6 +76,10 @@ jobs: | |||
path: example/android/app/build | |||
key: ${{ runner.os }}-build-${{ env.cache-name }}-example-${{ hashFiles('**/react-native/package.json') }} | |||
|
|||
- name: Build Android app | |||
working-directory: example/android | |||
run: ./gradlew assembleDebug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this takes 20 minutes, I would build in a separate job, publish the APK as artifact and then download the artifact separately, or use Gradle cache to make sure the whole building running FROM-CACHE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes a lot of sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the latest version now omits starting the Emulator - but wouldn't we need another build file / step that starts and runs the emulator? Or I'm I misunderstanding that we already have this...? (🫣)
- name: Build Android app | ||
working-directory: example/android | ||
run: ./gradlew assembleDebug | ||
|
||
- name: SKDs - download required images | ||
run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;default;x86_64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to docs the emulator startup time can be greatly reduced by caching, see reactivecircus/android-emulator-runner
Any reason doing this manually?
.github/workflows/android.yml
Outdated
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 29 | ||
script: ./gradlew connectedCheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still do a full build before deploying the APK and running tests. But I'll leave it up to the team to figure out what you want :)
@chrfalch This is finally ready for review. It splits the Android build and test into two jobs. That way, if the emulator crashes, which seems to happen on Github actions, we can just restart the testing job without rebuilding the apk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Lately the Android Github action has been extremely flaky and it seems like many open source projects are affected by the same issue (see mockito/mockito#2903).
More specifically, the issue if that once we finished to build the app, the emulator is not responsive anymore.
While there doesn't seem to be any great solution for this yet, I was wondering if we should build the app before starting the emulator. One possible cause of this problem is that the github image is so constraint in resources that it may crash the emulator. Overall I think it is good to build the app first anyways, if the CI fails because of a build error, we will get the error much faster.
Another suggestion was to downgrade the Android API version.