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

Gradle Managed Devices #76

Closed
hannesa2 opened this issue Nov 12, 2022 · 7 comments
Closed

Gradle Managed Devices #76

hannesa2 opened this issue Nov 12, 2022 · 7 comments

Comments

@hannesa2
Copy link
Contributor

hannesa2 commented Nov 12, 2022

I tried to use Gradle Managed Devices https://developer.android.com/studio/test/gradle-managed-devices


      - name: Run instrumentation tests
        uses: malinskiy/action-android/emulator-run-cmd@release/0.1.4
        with:
          cmd: ./gradlew nexusOneApi30DebugAndroidTest
    testOptions {
        managedDevices {
            devices {
                nexusOneApi30(com.android.build.api.dsl.ManagedVirtualDevice) {
                    // A lower resolution device is used here for better emulator performance
                    device = "Nexus One"
                    apiLevel = 30
                    // Also use the AOSP ATD image for better emulator performance
                    // The androidx.test screenshot APIs will automatically enable hardware rendering to take a screenshot
                    systemImageSource = "aosp-atd"
                }
            }
        }
    }

```but I run into 

Execution failed for task ':sample:nexusOneApi30Setup'.

A failure occurred while executing com.android.build.gradle.internal.tasks.ManagedDeviceSetupTask$ManagedDeviceSetupRunnable
java.lang.IllegalStateException: Gradle was not able to complete device setup for: dev30_aosp_atd_x86_Nexus_One
This could be due to having insufficient resources to provision the number of
devices requested. Try running the test again and request fewer devices or
fewer shards.


Does someone knows, how to use Gradle Managed Devices with Github actions ?
@Malinskiy
Copy link
Owner

The action you are using here spins emulator before the GMD. There is barely enough resources to run one emulator.
To use gmd just run without using the emulator action

@hannesa2
Copy link
Contributor Author

Even with this, I run into same error

  - name: Install Android SDK
    uses: malinskiy/action-android/install-sdk@release/0.1.4
  - name: Build project
    run: ./gradlew nexusOneApi30DebugAndroidTest

@hannesa2
Copy link
Contributor Author

hannesa2 commented Nov 12, 2022

Even

  - uses: malinskiy/action-android/install-sdk@release/0.1.4
  - run: sdkmanager platform-tools
  - run: ./gradlew nexusOneApi30DebugAndroidTest

shows me

* What went wrong:
Execution failed for task ':sample:nexusOneApi30Setup'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.ManagedDeviceSetupTask$ManagedDeviceSetupRunnable
   > java.lang.IllegalStateException: Gradle was not able to complete device setup for: dev30_aosp_atd_x86_Nexus_One
     This could be due to having insufficient resources to provision the number of
     devices requested. Try running the test again and request fewer devices or
     fewer shards.

a running example would be nice

@Malinskiy
Copy link
Owner

Sorry, what do you mean by a running example? The action doesn't mention anything about compatibility with GMD. If it doesn't spin the device requested by your GMD configuration, then this means it's a GMD configuration problem

If you really want to use GMD (which you shouldn't in my personal opinion), then I suggest starting out by copying the config from the action that works into the GMD spec of devices

@hannesa2
Copy link
Contributor Author

hannesa2 commented Nov 13, 2022

The action doesn't mention anything about compatibility with GMD.

Exactly this I try to test, if it works with this/any action

If it doesn't spin the device requested by your GMD configuration, then this means it's a GMD configuration problem

Hmm, not sure. I use sample to test with action. At least locally it works like a charm
https://github.com/hannesa2/testing-samples/pull/1/files#diff-b71166ed0f585913318ed46933ff9b12901e211de3ac88c40de03f0a944c0ae0R25-R27

If you really want to use GMD (which you shouldn't in my personal opinion)

Just curious, why do you not recommend it ?

then I suggest starting out by copying the config from the action that works into the GMD spec of devices

What do you mean ?
In my point of view, when I'm using working main sample, I expect a working sample (locally I can confirm)
But with Github action, it doesn't work. My suspect is the action somehow.

@Malinskiy
Copy link
Owner

It's quite possible that your local environment is much faster than the macos worker on GitHub via macstadium hence the need to tweak the emulator down in terms of resource consumption.

GMD can run any emulator configuration with arbitrary resolution of screen. The hardware on GH worker is very limited and needs as fast as possible emulator which is setup here in the action. When you try to use GMD on your laptop/server you control the resources and you can allocate more CPU/RAM. This is not the case on GH and practically there is no much you can change on GH in the emulator in terms of parameters of the emulator itself. If you ask for too much - the emulator will just fail booting in time. The action has nothing to do with GMD since GMD uses avdmanager transitively via a separate process and utilises the https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:utp/android-device-provider-ddmlib/.

As for why I advise not to use GMD - spinning up devices for testing is not a build system concern and should be solved in a different architectural component

To make your setup work you need to provide the same config of emulator that is known to work as of now on GH to the GMD

@hannesa2
Copy link
Contributor Author

Thanks a lot for the explanation.
Thanks to your link, I found the relevant line in code.

To make your setup work you need to provide the same config of emulator that is known to work as of now on GH to the GMD

This is the point where I've no knowledge, how to figure out my config of emulator and apply to GDM ?
Is it the config.ini of the emulator, or even all *.ini of an emulator

./hardware-qemu.ini
./config.ini
./advancedFeatures.ini

I guess I've no chance to apply it to GDM device

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants