Security & Reverse Engineering

Hardcoded API Keys in APKs: Separate Public Identifiers from Secrets

A string that looks like an API key is not automatically a confidential secret. The important questions are what the credential authorizes, whether it is designed to be public in a client, and which restrictions prevent misuse if someone copies it from the APK.

By Updated 2 min read

Classify before reacting

Item Typical concern
Public project or app identifier Correct project association and configuration
Client API key with service restrictions Scope, application restrictions and abuse monitoring
Backend administrator credential Immediate exposure requiring revocation and investigation
User access token Lifetime, storage, leakage and server-side authorization
Private signing key Release identity compromise; should not be packaged

Firebase explains that its client API keys are generally identifiers rather than authorization secrets. That does not make every Google Cloud API key harmless or replace Firebase Security Rules and other access controls.

Inspect the capability, not the label

For each detected value, record its source file, owning service, allowed APIs, application restrictions and revocation process. Redact the value in tickets. Do not “test” a discovered third-party credential against services you are not authorized to access.

For your own exposed secret, revoke or rotate it through the provider and review access logs. Removing the string from the next release does not invalidate copies of an already distributed APK.

Keep privileged operations on the server

A mobile client is distributed to users and can be inspected. Do not embed a backend administrator key and rely on obfuscation to keep it secret. Use authenticated, narrowly authorized server operations instead.

Build-time secret injection prevents accidental repository commits, but it does not make a value confidential once compiled into the client. The Secrets Gradle Plugin helps manage local configuration; it is not an encryption boundary around distributed credentials.

Verify the release and restrictions

Inspect the final package, including assets and generated resources. Check the actual service-side restrictions using a controlled test app or environment. Make sure debug and release signing fingerprints are handled correctly where the provider uses them.

Use scanner output responsibly

APKLint's security tools can surface key-like strings and risky configuration. Treat those as leads. A finding needs service context before it can be labeled a credential leak, and a scan without matches cannot prove that all secrets are absent or that backend access controls are correct.

Sources and further reading

  1. Firebase: API keys
  2. Google Maps Platform: Secrets Gradle plugin
  3. Android Developers: Security best practices

Reference review: 22 September 2026. Examples illustrate the workflow; check your installed versions, release artifact and account-specific Console requirements before applying them. This guide is not a claim that APKLint executed your project or verified your private account.

APKLint

Android inspection tools and practical release guides. About APKLint · Report a correction