Android Gradle Managed Devices fails to boot emulator - android

When I try running 3 shards of a Pixel 4 API 31 image for Android Emulators, I am getting
Device provider <com.android.tools.utp.plugins.deviceprovider.gradle.GradleManagedAndroidDeviceProvider> failed trying to provide device controller.
Gradle was unable to boot one or more devices. If this issue persists,
delete existing devices using the "cleanManagedDevices" task and rerun
the test.
com.android.tools.utp.plugins.deviceprovider.gradle.GradleManagedAndroidDeviceLauncher$EmulatorTimeoutException: Gradle was unable to boot one or more devices. If this issue persists,
delete existing devices using the "cleanManagedDevices" task and rerun
the test.
I am running it by using
./gradlew pixel4api31DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=aaa.bbb.ccc.ddd.Suites.CITestSuitePartA -Pandroid.experimental.androidTest.numManagedDeviceShards=3
Using 2 shards works, but using 3 fails with this error. Does this mean that there aren't enough resources on my mac to be able to run 3 API 31 emulators? API 30 works with 3.

Related

Running DJI-SDK Android ImportSDKDemo is failing with INSTALL_FAILED_MISSING_SHARED_LIBRARY

I followed the instructions in https://developer.dji.com/mobile-sdk/documentation/application-development-workflow/workflow-integrate.html#android-studio-project-integration.
* The Android Studio project build is successful
* I created the API-KEY according to the instructions and populated it in the AndroidManifest.xml
When I click on run app on Nexus 5 emulator on my PC, the emulator is open and running but the installation of the DJI app is failing with the following error:
04/01 20:54:58: Launching 'app' on Nexus 5X API 28 x86.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Installation failed due to: 'null'
What am I missing?
You can't run DJI-SDK in emulator, you must use a physical device.
It might be possible, but it's nothing I recommend bother with.

Android Studio refuses to build and install any app on my phones

Since the time I have updated android studio to 3.5, I have been unable to run any app on multiple of my physical phones (Redmi Note 4 and OnePlus6). The app isn't installing on any of them. But it is installing on the emulated devices of the same respective versions (Android 24 and Android 28), so it is not an issue with the code.
Moreover, I tried to build the previous versions of my app stored on Git, and now Android Studio does not build the app showing - "linking error". While that same code version was working fine a few months ago (prior to the android studio update). Which is why I think the problem is somehow with the Android Studio and not the code...
Things I have tried
Disable instant Run (Not an option anymore in Android Studio >=3.5.1)
Enable USB debugging, connect using the device using "Transfer Files" mode and not "Charging Device" Mode
Turn off MIUI Optimization and Reboot
Uninstall App and re install
Build the apk, transfer the apk to the device and then try the install (This works on OnePlus 6 but not on Redmi Note 4)
The apps I have tried target Sdk >=27, and use androidx. However, I tried to go back to a previous version of the app, which didn't use androidx (and used the legacy support libraries), but still got the same error.
My system is Ubuntu 18.04, and current Android studio version is 3.5.3
Errors I have been getting include:
INSTALL_FAILED_USER_RESTRICTED
Device Not Found
UPDATE:
- Just tried to install on OnePlus6, doesn't install there as well. Earlier I had tested only for Redmi Note 4.
- Tried uninstalling and reinstalling the app, building the apk and
transferring on the phone then manually installing.
- This is happening across projects, at least for Redmi Note 4. I tried this with one of my course projects, same/similar problems.
My guess is problems with Android Studio update and the recent migration to androidx from the "legacy" support libraries
How I solved it:
Disable "Use libusb backend" in the Settings -> Build, Execution and Deployment -> Debugger
Sorry Android Studio 3.5 for the curses
How I found the solution:
I checked the logs of android studio by going to Help -> Compress Logs and Show in Files. In the folder which opened, I saw the logs by the name adb.1000.log (because adb - android debug bridge, handles the communication with the device). In the last few lines I saw - "read transfer failed: LIBUSB_TRANSFER_CANCELLED". I read here about the option of libusb
Did you try to clean/rebuild... under /Build/Clean Project, after that /Build/Rebuild Project and after cleaning and rebuilding you can try under /File/Invalidate caches

Could not update files on device: HttpException: Connection closed before full header was received

I have build a flutter app and when try to run on older version of android API 16 it shows an error unfortunately app has stopped.In console it is showing an error could not update files on device: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:64386/UnbKN1wrm_A=/
In the discussions opened in GitHub, it seems that the culprit of the error is the Android Q Emulator itself.
Here are the issues related to this:
Error connecting to the service protocol when using Android Q beta emulator image
flutter run: Error connecting to the service protocol on Android Q (API level 29) emulator
And since this is an emulator issue, I think the best option is to wait for the update or try to run your Flutter app in a physical device as suggested.
Some temporary workaround if physical device is not available is to create another emulated device like Pixel 2 Android 9.0 Target (28 API).

Android emulate failed using AOSP source

I downloaded Android full sources 5.1, 6.0, 7.0 and built them.
I tried to check if the builds worked using the android emulator in the SDK, but they all failed except version 5.1.
I replaced the original image files (system.img, ramdisk.img, and userdata.img) with newly built files, and then ran them. However, the Android logo never appeared, and the OS didn't boot.
I chose mini-emulator-arm-debug and the original emulator image of the same version and AOSP.
I don't know why android 5.1 boots but android 6.0 and 7.0 don't. Has the method of executing the images in an emulator changed?
Please help me.
Building from source succeeds in all three cases.
On execution, the emulator screen shows only black. I tried to connect using adb shell but failed.
Please try to run
lunch full-eng
and when finished, run the emulator.

Using gradle to test android apps in an emulator

Ok I want to use gradle to run my tests in an emulator.
gradle has two targets that allow me to run tests:
connectedCheck
deviceCheck
If I understood correctly, we should use deviceCheck to test stuff in an emulator, but when I run it runs no tests.
connectedCheck also doesn't work because it can't find a device (emulators don't appear in the Android Studio the way my cell phone do).
What I would like is (ideally):
run my gradle script
it boots up an emulator
it runs tests on that emulator
it turns down the emulator
I would also like to have a target that won't boot or turn down the emulator, but it will use one if one is up.
It's possible to do any of these things? I can't find documentation anywhere on how to configure gradle android plugin.
An emulated device is a connected device. I can't tell that gradle has a way of starting an emulator for you short of an Exec task. I leave a couple emulators always running in the background with -no-window, and on our CI I did up a little bash script to fire up a few at various API levels before gradle is invoked and then shut them down afterward.
I came here searching for an example of how deviceCheck is used. It seems like it's supposed to be self-evident.

Categories

Resources