Import contacts from google account to Android Emulator - android

I'm using the Android Studio emulator, specifically a Pixel 2 emulator running Android 7.1.1 with Google APIs.
In my team we have a Google test account that has all sort of contacts that are useful for us for development and testing.
I have connected the emulator to this Google account (by going to Settings -> Accounts -> Add account -> Google) however I'm still unable to see the accounts associated with the Google test account in the device's "Contacts" app.
I've looked in account page and made sure that the syncing for "Contacts" is toggled on. I even tapped on "Sync now" but still I don't see any contacts in the "Contacts" app.
For comparison, we also have physical test devices in the team that are connected to this Google test account and there it works fine - the contacts are synced to the physical test device. So it seems to only be an issue with the Android Studio emulator (on GenyMotion emulator it also works).
How do I fix this issue?
I've attached two screenshots, one for the contacts app and the 2nd one for the Google account page.
In the 2nd screenshot there is a refresh icon appearing next to contacts, but no matter how many times I perform "Sync now" it doesn't disappear.

Related

Is there a difference between D/FlutterGeolocator and D/FlutterLocationService?

So I'm building 2 apps, a user app and a driver app. Both are built successfully, but when installing on Android emulator they both show different things. The driver app show D/FlutterGeolocator: Binding to location service, and installs perfectly. However, when installing the user app it shows: D/FlutterLocationService: Binding to location service., and then gives out some error like: Lost connection to device.
Why do they both show different things? And how can I get the user app to show D/FlutterGeolocator so it might just install like the driver app.

Android Virtual Device for Huawei Mobile Services

I want to apply HMS to my app. However, buying an actual Huawei phone is not on my shortlist. Does Huawei provide an Android Virtual Device for that purpose? If not, how to test if my implementation of HMS actually works?
Yes, Huawei do provide an Android Virtual Device called Cloud Debugging of AppGallery Connect to test your app for Huawei Devices.
Cloud Debugging tests your app using mainstream Huawei devices provided by Huawei. You can run your app on the latest and most popular Huawei devices to test app functions. Besides, you can debug apps on two real devices at the same time using one HUAWEI ID. Assume that you have applied for a device successfully.
Work with Cloud Debugging
Sign in to AppGallery Connect and select My projects.
Select an app to be tested.
Go to Quality > Cloud Debugging.
Filter devices by Series, Android version, EMUI version, and Resolution.
In the Apply for device model dialog box that is displayed, set Debug duration based on your needs. The options are 30 min, 1 h, and 2 h.
Wait for the device initialization to finish.
Click the Debugging tab.
Click Upload to upload an APK.
Check the APK upload progress and install the APK after the upload is complete.
In the displayed dialog box indicating that the app is being installed, click OK. When the installation is complete, you can see the app icon on the device screen on the left.
Operate the device by moving or clicking your cursor on the device screen, or clicking the power button, home button, menu button, or back button. The device will respond like your own phone.
Check Screenshot below:
From: https://stackoverflow.com/a/63389096/13329100
If you don't have HMS device your side you can run HMS Application in three ways.
1. Huawei Cloud Debugging in App Gallery: In this method first we have to sign in App Gallery. You can see the article "Efficient integration of HMS open capabilities by using HUAWEI Cloud Debugging solution" for the step by step process of cloud debugging.
2. Cloud debugging through HMS ToolKit: Here first we have to install HMS Tool Kit plugin in Android Studio.You can use the article "Debug your application on any HMS Supported Model using HMS Toolkit Cloud Debugger - No Real Device Required" for step by step process.
3. Installing HMS Core App in your non HMS Device: You can install HMS Core app in your non HMS device. Once install it will ask to update the app. This will help you to run some Kits like awareness, ML, Ad etc in your device. Once we install we have to go to Settings->Apps and search for 'HMS Core'and grant the location or other permissions which are required.
Hope any of these method will help you.

Is there any effective way to test an app for the Huawei Store using Android Studio emulator?

I would like to know if there is any effective way to test an app for Huawei Store using an Android Studio emulator.
I tried disabling the Google Play Services, but for some reason Retrofit requests stopped working :/
You can use Cloud Debugging of AppGallery Connect to test your app for Huawei Devices.
Cloud Debugging tests your app using mainstream Huawei devices provided by Huawei. You can run your app on the latest and most popular Huawei devices to test app functions.
Work with Cloud Debugging
Sign in to AppGallery Connect and select My projects.
Select an app to be tested.
Go to Quality > Cloud Debugging.
Filter devices by Series, Android version, EMUI version, and Resolution.
In the Apply for device model dialog box that is displayed, set Debug duration based on your needs. The options are 30 min, 1 h, and 2 h.
Wait for the device initialization to finish.
Click the Debugging tab.
Click Upload to upload an APK.
Check the APK upload progress and install the APK after the upload is complete.
In the displayed dialog box indicating that the app is being installed, click OK. When the installation is complete, you can see the app icon on the device screen on the left.
Operate the device by moving or clicking your cursor on the device screen, or clicking the power button, home button, menu button, or back button. The device will respond like your own phone.
Check Screenshot below:
You can check out the official documentation for a more complete answer.
For most cases, you can simply grab HMS Core APK and install it on emulator or physical device
You do not need for most cases Huawei device. Here is my battle-tested solution.
If you're implementing HMS (Huawei Mobile Services) feature like push notifications, sms retrieving or auth(orization) you can do simply:
Grab HMS Core APK from: https://www.huaweicentral.com/download-the-latest-huawei-mobile-services-apk/
Create new or run existing Android emulator via Android Studio or ADB
Install HMS Core APK downloaded from 1.
Go to Settings -> Apps & Notifications
Make sure that HMS Core has required permissions like SMS for SMS retrieving or push notifications
If you forget about 5., HMS library will return exception "Permissions not enabled"
I am pretty sure that instead of emulator you can use any of physical devices, grab APK and install HMS Core on it.
From: https://stackoverflow.com/a/63790263/4730812
Happy coding!
Well, I was trying here to make Retrofit work in this condition and I found a way.
I don't know if it is the best solution, but I will post it anyway.
disable the Google Play Services;
force stop your app;
restart the emulator;
check if it is working now (if not, try to force stop your app again).
P.S.: Google Play Services is not re-enabled upon reboot.

AccountManager fails to add account on Sony XZ 7.1.1

The app I'm currently developing has recently been showing problems when users update to 7.1.1 om Sony mobiles
On a Sony XZ we can see this in the log when trying to addAccountExplicitly:
AccountManagerService( 1503): insertAccountIntoDatabase: Account {name=something#something.com, type=com.myapplication.go}, skipping since the account already exists
The application was installed and the account was added by our app prior to upgrade. It seems as if the account has not been completely removed/readded.
How can we in our app recover from this?
Why is this happening?
I have read of similar problems in Nougat preview but we can not recover from it with removeAccountExplicitly and then add it again as suggested in link below. The result is the same as above and uninstallation of the app does not clear the account and neither does a phone restart.
AccountManager does not add custom account in Android N preview
We found a possible cause and solution for the problem.
Symptoms
TL;DR It's Sony's fault.
From our user base, it looked like only Sony XZ users who used our app prior to upgrading their device to 7.1.1.
We went as far as buying several Sony XZ devices (and eventually returning them back to the shop), upgrading them from Android 6.0 to 7.1.1 and trying to reproduce the issue. But with no luck.
However, we found another way to achieve the same "symptoms" using the Android emulator. The steps are:
Launch emulator
Login into your app (so that user is added to AccountManager)
Go to the terminal, and do the following
Steps:
adb shell
su
cd /data/system_de/0/
rm accounts_de.db
Restart your emulator
From now on your issue is reproducible.
Moreover, if you'll check /data/system_ce/0/accounts_ce.db you will see that this is a database which still contains your previous user. That is most likely why AccountManager does not allow you to insert same user again.
It looks like that during update to Android 7.1.1, Sony somehow corrupted accounts_de.db which contained the original account.
Solution
Since account with the same name is already in the database (and you can't really remove it from there), we basically can't insert user with the same username again. However, we can insert account with slightly updated username:
if (!accountManager.addAccountExplicitly(account, password, bundle)) {
// We failed to add the account. Fallback to workaround.
accountManager.addAccountExplicitly(
new Account(username + "\n", accountType), // this line solves the issue
password,
bundle
);
}
Since this account is now different from original account (thanks to \n character), it can be inserted into AccountManager database.
The issue is known by Google: https://issuetracker.google.com/issues/142699760

Android Emulator: Calendar application will not synchronize with google calendar

I would like to reopen this question since I am having the same problem:
Use Calendar within emulator Android 4.0 +
Namely, I see a Calendar application on virtual devices running android 4.0
or later (there is no calendar application on android 3.2 even though my physical
gingerbread phone has once such an app, which I find strange). However I am not
able to synchronize the data on the android 4.0 or later emulator with my google
account's calendar data. Here are the details:
I had created an Android 4.2.2 emulator and launched the calendar application
from within such an emulator. I want to sync my google account with the calendar
application. So I hit menu -> Settings -> ADD ACCOUNT. Nothing happens. So I tried
to hit menu -> Calendars to display -> Calendars to sync, but the list is empty
and hitting menu does not bring up a menu.
I suspected the problem was I needed google apis to work. So I created a new
4.2.2 virtual device with google apis. When I launched such emulator and then the
calendar application I got a screen saying "Make it Google", "Do you want to add
an existing account or create a new one?". Click on Existing. I entered my
sign in details. I click on the popup asking me to agree to google terms
of service, and I accepted. It then says "Signing in..." "This can take a few minutes."
The Backup and Restore screen shows up and I click forward and proceed. However I
do not see the contents of my google calendar's account on the android calendar.
When I launch the calendar application again it asks me once again to
"Make it Google" and enter my account information. If I enter the old
information it complains telling me I have already specified such an
account. However my google account's data does not show up in android calendar.
I cannot understand why or what I am doing wrong.
(Alas I do not have a 4.0+ phone to test with so I am stuck having to get
the emulator to work).
Thanks for your feedback,
Jason Posit
I know this is older, but I did find a solution. I was never able to get a Google account to work since Google blocks active sync on free accounts.
The solution for me was to signup for a free outlook.com account and use outlook.com's active sync settings.
The steps I followed are from my blog and are as follows:
Sign out for free account at outlook.com
Select a Corporate Account
Enter username such as email#outlook.com
Select Manual Setup
Select account type of “Exchange” (This will allow us to sync with active
sync)
Enter Server as s.outlook.com
Security type as SSL/TLS
Select next
Confirm settings.
As "Corporate Account" type isn't being provided in newer emulator images, one can install custom CalDAV adapter, which amusingly does work with Google's CalDAV interface.

Categories

Resources