App running on android studio emulator but not on real device :( - android

I am new to android and I was making an app using firebase authentication to let a user create an account and sign in. While making the app, I set the minimum android version to Marshmallow. Every thing works well when I run the code on the emulator.
I have made a variable name isAdmin and a EditText which is secret code, so when a user creates an account, if the user knows the secret code, he or she will get admin rights, else no admin rights will be given.
The problem is that when I run the app on the emulator it works fine, when I run using USB debugging in my phone it works fine, but when I generate an apk in Android Studio and install that app on my mobile and then I create an account, the app crashes without showing any error and when I look into my firebase database, all details like first name, last name exist in database but the variable isAdmin does not exist in the database.
I don't know why this variable is not getting stored in the database.
My phone is Marshmallow xiomi redmi 3s

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 device id doesn't match on Physical Device & Emulator

I found an application & they are using Device Identity as user login. After uninstall & install its showing same DeviceID.
When I test this app on my android device. The device identity doesn't match with this String.
String android_id = Settings.Secure.getString(this.getContentResolver(),
Settings.Secure.ANDROID_ID);
But when I tried this on android emulator string matched with that app device ID.
But in my physical Device....
Showing on that app: 93edad60438f8004
Getting String Device ID: 5f1cf6393c37ae96
How can I get device ID as that application?
That App on Emulator
Emulator Device ID
As of Android 26, every app on the device gets told a different Android ID for privacy reasons. This prevents companies from being able to share data on a user without his permission by just correlating the device id.
Also, a device id should NEVER be used as login credentials. I can get a version of Android that allows me to claim whatever id I want on an emulator with a quick recompile of AOSP. It can be spoofed way too easily. If you need to be able to log in a device, use a randomly generated key from your server and encrypt it with a key stored in the keystore. Do not count on an hardware identifier. They can be spoofed, and just as importantly you can't revoke them without breaking the user's ability to use your app. With a randomly generated token you can invalidate it server side and the user just has to log in again.

How to enroll device onto android enteprise?

I have created Android enterprise then enrolled the device on using the QR code, the device does say its enrolled and managed by Organisation. But the weird part is it trying to get the list of device return empty object, and also the app which I had put on policy to be forced to install didn't install. What could be the problem in my enrollment?

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

Facebook login on unity android app problems

I am testing an android app I created in Unity on my Galaxy S4 and I successfully log in, and everything works great! However, while changing no settings, I test my app on a Moto X device, and when I click login button and accept permission request. Nothing happens, and I do not log in.
Is their something specific I need to provide to handle different android devices to successfully use the facebook sdk?
Any tips or help is greatly appreciated!!
It should work regardless of the device
Just make sure you are asking for read only permissions during FB login (e.g. email permission)... after successfully getting the read permission then you should be able to ask for write permissions such as uploading photos...etc
switch to development build and see what the android console log show? you should at least get some errors

Categories

Resources