Home > Back-end >  flutter signature do not match and problem with AndroidId
flutter signature do not match and problem with AndroidId

Time:07-17

  • I am working on a Flutter project , where I am checking the AndroidId of a device while loading the app, using the device_info_pluging package.

  • I am working on the project on 2 computers, usually switching between them twice a week, pulling and pushing the changes to/from GitHub private repository.

  • Working with a physical phone for testing (since the app uses Bluetooth).

I am constantly facing 2 strange problems:

1. whenever I run the app in the first time on a computer (after pulling changes from GitHub), I get the below message - Signatures do not match. enter image description here

I would accept the fact i need to uninstall/reinstall the app when switching between computers for signatures, but.....

The 2nd problem I am facing is really strange.

2. The AndroidId of the device I am using (old Samsung S7) is changing between the computers

I am using this function to pull the AndroidId from the device (or the identifierForVendor if i would use iPhone).....

Future<String> getDevInfo() async {
  final deviceInfoPlugin = DeviceInfoPlugin();
  if (Platform.isAndroid) {
    final deviceInfo = await deviceInfoPlugin.androidInfo;
    deviceHostName = deviceInfo.androidId.toString();
  } else if (Platform.isIOS) {
    final deviceInfo = await deviceInfoPlugin.iosInfo;
    deviceHostName = deviceInfo.identifierForVendor.toString();
  }
  return deviceHostName;
}

on each computer the device (The Samsung S7) shows a different AndroidID.

here are the screenshots of the same device from 2 different computers. (My apologies for the quality of the images)

Computer 1 is a Dell Workstation,

Computer 1 Device Info

Computer 2 is a Dell Laptop,

Computer 2 Device Info

The screenshots describe all the DeviceInfo Object, to emphasize that the other properties are exactly the same.

Do my problems relate to each other? I would have tolarated the first prblem if wouldn't have faced the second, or do they have nothing to do with each other?

CodePudding user response:

So, In the end, it was all about the signing of the app, Thanks to @unsoop.

I have signed it according to deployment instructions in

Android deployment guide

and used the signature for debug rather than release as follows.

The moment I have signed the app with a jks file and added to the build.gradle the keyStoreProperties in the debug signing config, like:

  signingConfigs {
    debug {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] 
        ? file(keystoreProperties['storeFile']) 
        : null
        storePassword keystoreProperties['storePassword']
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
}

everything is running smoothly.

I get the same AndroidID in both computers, obviously different from the 2 old IDs that where generated previously (solution to 2nd problem).

p.s.: since Android Oreo, AndroidID is created not per device but per app and user in a device, for enhanced security.

And when updating the app in one of the computers and reverting to the other, it does not require to reinstall, since there is no signing error (solution to 1st problem).

This solution will also need a Release signingConfig when will be uploaded to the Store, and although could be the same, I guess the best practice will be to create a new jks file for the release.

CodePudding user response:

First of all, issue 1 & 2 are not related.

Issue 1:

You can see that the error is signatures dose not match previously installed version , that means you already have a version installed with a different key.

reson for such behavior can happen when you use different keys. You should work with the same key on all devices (should be different key for each app)

https://developer.android.com/training/articles/keystore

Issue 2:

As long as the app is not signed, every copy of the app will get its own AndroidID.

  • Related