fluttercommunity / plus_plugins

Flutter Community Plus Plugins
BSD 3-Clause "New" or "Revised" License
1.56k stars 948 forks source link

[Bug]: Can't get androidID #939

Closed kaichun831 closed 2 years ago

kaichun831 commented 2 years ago

Platform

Android 11

Plugin

device_info_plus

Version

4.0.0

Flutter SDK

2.10.3

Steps to reproduce

null

Code Sample

var myDeviceInfo = DeviceInfoPlugin();     
var device = readAndroidBuildData(await myDeviceInfo.androidInfo);
mobileId = device['androidId'].toString();  // null

Logs

{version.securityPatch: 2020-11-05, version.sdkInt: 30, version.release: 11, version.previewSdkInt: 0, version.incremental: 7027799, version.codename: REL, version.baseOS: , board: goldfish_x86_64, bootloader: unknown, brand: google, device: generic_x86_64_arm64, display: RSR1.201211.001, fingerprint: google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys, hardware: ranchu, host: abfarm394, id: RSR1.201211.001, manufacturer: Google, model: sdk_gphone_x86_64, product: sdk_gphone_x86_64, supported32BitAbis: [x86, armeabi-v7a, armeabi], supported64BitAbis: [x86_64, arm64-v8a], supportedAbis: [x86_64, x86, arm64-v8a, armeabi-v7a, armeabi], tags: release-keys, type: user, isPhysicalDevice: false, androidId: null, systemFeatures: [android.hardware.sensor.proximity, android.software.adoptable_storage, android.hardware.sensor.accelerometer, android.software.controls, android.hardware.faketouch, android.software.backup, android.hardware.touchscreen, android.hardware.touchscreen.multitouch, android.software.print, android.software.activities_on_secondary_displays, android.software.voice_recognizers, android.software.picture_in_picture, android.hardware.fingerprint, android.hardware.sensor.gyroscope, android.software.vulkan.deqp.level, android.software.cant_save_state, android.hardware.sensor.relative_humidity, android.hardware.bluetooth, android.hardware.camera.autofocus, com.google.android.feature.GOOGLE_BUILD, android.hardware.telephony.gsm, android.software.incremental_delivery, android.hardware.camera.concurrent, android.hardware.audio.output, android.software.verified_boot, android.hardware.camera.flash, android.hardware.camera.front, android.hardware.screen.portrait, android.hardware.sensor.ambient_temperature, android.software.home_screen, android.hardware.microphone, android.software.autofill, android.software.securely_removes_users, android.hardware.bluetooth_le, android.hardware.sensor.compass, android.hardware.touchscreen.multitouch.jazzhand, android.hardware.sensor.barometer, android.software.app_widgets, android.software.input_methods, android.hardware.sensor.light, android.hardware.vulkan.version, android.software.companion_device_setup, android.software.device_admin, com.google.android.feature.WELLBEING, android.hardware.wifi.passpoint, android.hardware.camera, android.hardware.screen.landscape, android.hardware.ram.normal, android.hardware.sensor.hinge_angle, android.software.managed_users, android.software.webview, android.hardware.camera.capability.manual_post_processing, android.hardware.camera.any, android.hardware.camera.capability.raw, android.hardware.vulkan.compute, android.software.connectionservice, android.hardware.touchscreen.multitouch.distinct, android.hardware.location.network, android.hardware.camera.ar, android.software.cts, android.hardware.camera.capability.manual_sensor, android.software.app_enumeration, com.google.android.apps.dialer.SUPPORTED, android.hardware.camera.level.full, android.hardware.wifi.direct, android.software.live_wallpaper, com.google.android.feature.GOOGLE_EXPERIENCE, android.software.ipsec_tunnels, com.google.android.feature.EXCHANGE_6_2, android.hardware.location.gps, android.software.midi, android.hardware.wifi, android.hardware.location, android.hardware.vulkan.level, android.software.secure_lock_screen, android.hardware.telephony, android.software.file_based_encryption, null]}

Flutter Doctor

[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19044.1766], locale zh-TW)
    • Flutter version 2.10.3 at D:\software\KG\SDK\Flutter_SDK\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (4 months ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\USER\AppData\Local\Android\sdk
    • Platform android-32, build-tools 31.0.0
    • Java binary at: D:\software\KG\AndroidStudioFox\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.31911.196
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2020.3)
    • Android Studio at D:\software\KG\AndroidStudioFox
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] IntelliJ IDEA Community Edition (version 2021.1)
    • IntelliJ at D:\software\KG\IDE\IntelliJ IDEA Community Edition 2021.1.1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19044.1766]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 102.0.5005.115
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 103.0.1264.37
    ! Device emulator-5554 is not authorized.
      You might need to check your device for an authorization dialog.

[√] HTTP Host Availability
    • All required HTTP hosts are available
alexmaycon commented 2 years ago

Same here on v4.0.0 but on Change Log:

popsams commented 2 years ago

Same here on v4.0.0 but on Change Log:

  • Breaking change Remove AndroidId getter to avoid Google Play policies violations

How to solve it?

alexmaycon commented 2 years ago

Same here on v4.0.0 but on Change Log:

  • Breaking change Remove AndroidId getter to avoid Google Play policies violations

How to solve it?

I started to generate a unique identification (Uuid) and save it in the device's SharedPreferences and use this Uuid to identify it.

https://pub.dev/packages/uuid

devmuaz commented 2 years ago

@alexmaycon I would not recommend doing that, since once the user deletes the app and reinstall it again you will get a different uuid which it isn't the same one the user had perviously.

alexmaycon commented 2 years ago

@alexmaycon I would not recommend doing that, since once the user deletes the app and reinstall it again you will get a different uuid which it isn't the same one the user had perviously.

I understand, but in my case this is not a problem, the function is just to identify the device after the user logs into the app.

UlasKasim-dusyeri commented 2 years ago

How are we achieving getting uniqueId, Uuid generation doesn't solve our problem

Sultandi commented 2 years ago

hi, i got this issue too (androidId = null)

trying downgrade with the version 3.2.4, and the androidId comeback. is there any solutions with latest version (^4.0.0) to achieve this androidId??

alexmaycon commented 2 years ago

How are we achieving getting uniqueId, Uuid generation doesn't solve our problem

https://developer.android.com/training/articles/user-data-ids

oakstair commented 2 years ago

Same here! UUID is not an ideal solution.

ttb-inc commented 2 years ago

Changed to using advertising ID. (Android only) It's not perfect, but ... (AD ID -> Hashing)

LoveBabyForeve commented 2 years ago

device:xiaomi11 androidId = null

qwkings commented 2 years ago

the same device , old project is ok, new project get the deviceid is null

LoveBabyForeve commented 2 years ago

使用^3.2.4版本,^ 4.0.0已经无法获取了,源码中已经删除了获取id的代码

nohli commented 2 years ago

FYI there is a new plugin for getting the Android ID 🙂 https://pub.dev/packages/android_id

devmuaz commented 2 years ago

@nohli nice work buddy!

mchudy commented 2 years ago

Why hasn't this been removed from the interface or marked as deprecated? It's really confusing that this method doesn't work on the newest version of the package.

jmgeffroy commented 2 years ago

FYI there is a new plugin for getting the Android ID 🙂 https://pub.dev/packages/android_id

Hi, thank you for this. Does it comply with Google Play's policies? I see it relies on Settings.Secure.ANDROID_ID

devmuaz commented 2 years ago

@jmgeffroy I believe it does, read carefully this section Google Play

nohli commented 2 years ago

@jmgeffroy I believe it does, read carefully this section Google Play

On that page, when collapsing Persistent identifiers, including Android ID, it says

Use for non-advertising purposes You can use persistent identifiers as long as you have a privacy policy and handle the data in accordance with the Developer Distribution Agreement and all applicable privacy laws in the areas where you make your app available.

devmuaz commented 2 years ago

@nohli Oh dear! didn't catch that actually, I focused on this one

Apps using a persistent ID other than the advertising ID may receive a policy violation warning via the publisher site or the email address used to register the account.

Thank You 🙏🏻

jmgeffroy commented 2 years ago

@jmgeffroy I believe it does, read carefully this section Google Play

On that page, when collapsing Persistent identifiers, including Android ID, it says

Use for non-advertising purposes You can use persistent identifiers as long as you have a privacy policy and handle the data in accordance with the Developer Distribution Agreement and all applicable privacy laws in the areas where you make your app available.

Hi, thanks! Yes, that's right. I double-checked the policies and we can use such IDs if we declare we do and explain why. Cheers

nohli commented 2 years ago

@jmgeffroy great! If you're interested, you could open a PR in the android_id README for explaining the necessary steps when using the id.

srnden commented 2 years ago

Hi. Why device_info_plus ^3.2.4 installed with device_info_plus_platform_interface 2.6.0, in which androidID was removed in version 2.5.0?

pubspec.lock:

device_info_plus:
    dependency: "direct main"
    description:
      name: device_info_plus
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.2.4"
  device_info_plus_linux:
    dependency: transitive
    description:
      name: device_info_plus_linux
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.1"
  device_info_plus_macos:
    dependency: transitive
    description:
      name: device_info_plus_macos
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.2.3"
  device_info_plus_platform_interface:
    dependency: transitive
    description:
      name: device_info_plus_platform_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.6.0"
  device_info_plus_web:
    dependency: transitive
    description:
      name: device_info_plus_web
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  device_info_plus_windows:
    dependency: transitive
    description:
      name: device_info_plus_windows
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.1"
nohli commented 2 years ago

@srnden because unfortunately the version was not updated as a breaking change (new major version).

You could use

dependency_overrides:
  device_info_plus_platform_interface: 2.5.0

Or maybe better, don't use overrides, use the latest version and also add android_id.

@miquelbeltran how about publishing a minor update of the platform interface, including the parameter androidId and also a major update without it?

2.7.0 would revert removing androidId 3.0.0 would add it again

miquelbeltran commented 2 years ago

Yeah, we need to be more careful, this is not the first time this happens.

The whole federated plugin architecture is a mess, and I am one more mess like this to refactor everything into plain old plugins.

I'll take care of reverting the change.

miquelbeltran commented 2 years ago

The reverted code has been published: https://github.com/fluttercommunity/plus_plugins/pull/1020

yingshaoxo commented 1 year ago

I think you guys may need this to get device id in Android:

https://pub.dev/packages/platform_device_id

ansar-859 commented 1 year ago

I think you guys may need this to get device id in Android:

https://pub.dev/packages/platform_device_id

ALERT: Seems like this package is not being maintained anymore.

nohli commented 1 year ago

https://pub.dev/packages/android_id