Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to add geofence: com.google.android.gms.common.api.ApiException: 1004: #72

Open
JuniorEC opened this issue Nov 17, 2020 · 1 comment

Comments

@JuniorEC
Copy link

I added geofence in my app similar to the example in this repository and I'm getting the following error:
W/ConnectionTracker( 7947): Exception thrown while unbinding W/ConnectionTracker( 7947): java.lang.IllegalArgumentException: Service not registered: com.google.android.gms.measurement.internal.zzji@84ae46d W/ConnectionTracker( 7947): at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1757) W/ConnectionTracker( 7947): at android.app.ContextImpl.unbindService(ContextImpl.java:1874) W/ConnectionTracker( 7947): at android.content.ContextWrapper.unbindService(ContextWrapper.java:792) W/ConnectionTracker( 7947): at com.google.android.gms.common.stats.ConnectionTracker.zza(com.google.android.gms:play-services-basement@@17.3.0:55) W/ConnectionTracker( 7947): at com.google.android.gms.common.stats.ConnectionTracker.unbindService(com.google.android.gms:play-services-basement@@17.3.0:50) W/ConnectionTracker( 7947): at com.google.android.gms.measurement.internal.zzio.zzag(com.google.android.gms:play-services-measurement-impl@@17.6.0:245) W/ConnectionTracker( 7947): at com.google.android.gms.measurement.internal.zzio.zzal(com.google.android.gms:play-services-measurement-impl@@17.6.0:262) W/ConnectionTracker( 7947): at com.google.android.gms.measurement.internal.zzio.zzc(com.google.android.gms:play-services-measurement-impl@@17.6.0:336) W/ConnectionTracker( 7947): at com.google.android.gms.measurement.internal.zzir.zza(com.google.android.gms:play-services-measurement-impl@@17.6.0:2)

My AndroidManifest:
`

<meta-data android:name="com.google.android.geo.API_KEY" android:value="0000000000000000000000000" />

<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
  <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
  <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
  <!-- Displays an Android View that continues showing the launch screen
             Drawable until Flutter paints its first frame, then this splash
             screen fades out. A splash screen is useful to avoid any visual
             gap between the end of Android's launch screen and the painting of
             Flutter's first frame. -->
  <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>
<!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data android:name="flutterEmbedding" android:value="2" />
<receiver android:name="io.flutter.plugins.geofencing.GeofencingBroadcastReceiver" android:enabled="true" android:exported="true" />
<receiver android:name="io.flutter.plugins.geofencing.GeofencingRebootBroadcastReceiver" android:enabled="true">
  <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED"></action>
  </intent-filter>
</receiver>
<service android:name="io.flutter.plugins.geofencing.GeofencingService" android:exported="true" android:permission="android.permission.BIND_JOB_SERVICE" />

`

Flutter doctor:
`

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.0, on Microsoft Windows [versão 10.0.18363.1198], locale pt-BR)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[!] Android Studio (not installed)
[√] VS Code, 64-bit edition (version 1.51.1)
[√] Connected device (1 available)
`

@DevarshRanpara
Copy link

Hi @JuniorEC ,
I was having same issues.
Error code 1004 mens app does not have enough permissions to operate, and that's why you are having that issue.
For refrence check this out.
You will need to add <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/> permission in your app.
You can use location_permissions plugin to get location permissions.
Make sure your app have background location permission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants