You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何使用声明权限的同证书签名应用?解决Google Maps空白问题

Fixing Blank Google Maps After Google Play Installation (Signature & API Key Issue)

Hey there, let's get to the bottom of this blank maps problem and clear up that permission confusion first!

First: Why Adding INTERACT_ACROSS_USERS_FULL Permission Doesn't Help

Let's break down that "signature" permission definition you're confused about:

"仅当请求权限的应用与声明该权限的应用使用同一证书签名时,系统才会授予该权限;证书匹配时系统自动授予,无需用户确认"

The INTERACT_ACROSS_USERS_FULL permission is declared by the Android system itself, not your app. For your app to get this permission, you'd have to sign your app with the same certificate Google uses to sign the Android OS—which is impossible for third-party developers. That's why adding this permission to your manifest (even with signature or signatureOrSystem protection level) does absolutely nothing. The log message about this permission is likely a red herring; the real issue is tied to your app's signature and Google Maps API keys.

The Root Cause: Mismatched Signatures & Google Maps API Key

When you run your app via USB debugging, you're using Android Studio's default debug certificate (from debug.keystore). But when you upload to Google Play, you're using your new release certificate (the one you created for generating signed APKs).

Google Maps API keys are locked to specific SHA-1 fingerprints (from your signing certificates) and your app's package name. If the fingerprint of the installed app doesn't match what's registered with your Maps API key, Google rejects the request—resulting in a blank map.

Step-by-Step Fix

1. Get the Correct SHA-1 Fingerprint

You need the SHA-1 of the certificate that's actually used to sign your app when it's installed from Google Play:

  • If you're using your own release keystore: Run this command in your terminal (replace placeholders with your file/alias names):
    keytool -list -v -keystore your-release-keystore.jks -alias your-key-alias
    
    Enter your keystore password when prompted, and copy the SHA-1 value from the output.
  • If you're using Google Play App Signing (most apps do this now):
    1. Go to your Google Play Console → Select your app → App signing (under the Release section).
    2. Look for the "App signing certificate" section and copy the SHA-1 fingerprint here—this is the one that matters, because Play re-signs your APK with this certificate.

2. Update Your Google Maps API Key

  1. Go to the Google Cloud Console → Select your project → APIs & ServicesCredentials.
  2. Find your Google Maps API key (the one you're using in your app's manifest or google_maps_api.xml).
  3. Edit the key's restrictions:
    • Under "Application restrictions", select "Android apps".
    • Click "Add an item" and paste the SHA-1 fingerprint you copied, followed by your app's package name (format: SHA1_VALUE;com.your.package.name).
    • Make sure you keep the debug SHA-1 if you still want to test locally, then save the changes.

3. Reupload Your App to Google Play

  • Generate a new signed APK (or App Bundle) using your release keystore.
  • Upload this new build to Google Play (either as a new release or update to an existing one). Once it's rolled out, the map should load correctly.

Quick Recap

  • Forget about INTERACT_ACROSS_USERS_FULL—it's a system-only permission you can't use.
  • The blank map is 99% due to your Maps API key not being authorized for your release/Play-signed certificate's SHA-1.
  • Always make sure your Maps API key includes all SHA-1 fingerprints that your app might be signed with (debug, release, Play App Signing).

内容的提问来源于stack exchange,提问作者CuriousPaul

火山引擎 最新活动