How to check your APK for leaked API keys before you publish

Updated

Anything inside your APK is readable by anyone who has a copy. An APK is a zip file. Free, widely used tools turn it back into readable resources and something close to your source code in a minute: apktool for resources and the manifest, jadx for code. Shrinking and obfuscation rename your classes and methods, but the text of a string, including a key, stays exactly as you wrote it.

So the useful question is not "is there a key in my app?" (there almost always is) but "is it one that is safe to be public?"

Which keys are safe to ship?

Some keys are designed to sit in client apps, because something else protects the data behind them:

  • Firebase API keys. Firebase's own documentation says keys "restricted to Firebase services" are "OK to include in code or checked-in config files". Your data is protected by Security Rules and App Check, not by the key. See what actually protects your Firebase data.
  • Supabase publishable (or legacy anon) keys. Supabase calls these "safe to expose" in a mobile app, on one condition: Row Level Security is enabled on every table. See whether your Supabase key is safe.
  • Payment providers' publishable keys, the ones meant for the client, as opposed to their secret keys.

"Safe to ship" still means restricted. Firebase recommends a separate, restricted key for any Google Cloud API that is not a Firebase service, rather than reusing the one in your app.

Which keys must never be in an APK?

Anything that grants access by itself, with nothing behind it checking who is asking:

  • Supabase secret or service_role keys. Supabase says: "Never put one in a browser, a shipped application, or source control." It refuses a secret key from a browser, but an Android app is not a browser, so from your APK it works, and used on its own it bypasses Row Level Security.
  • AI provider keys. Firebase says the key for the Gemini Developer API "should never be included in your code or configuration files." The same is true of any AI API key: whoever holds it runs requests on your bill.
  • Payment secret keys, cloud access keys and database passwords. These act as you, not as your user.

Where do keys hide in a build?

Rarely where you think you put them. Look in:

  • res/values/strings.xml and other resources, where configuration often ends up.
  • BuildConfig fields and .env values. Build-time variables are compiled into the app as constants. Putting a secret in .env keeps it out of git, not out of the APK.
  • assets/, including bundled JSON config files.
  • The JavaScript bundle in React Native and Expo apps (assets/index.android.bundle). Hermes compiles it to bytecode, but string literals are still in it.
  • libapp.so in Flutter apps, where Dart code is compiled ahead of time, string constants included.

How can I check my own APK?

Decode it and search it. With apktool and standard command-line tools:

apktool d app-release.apk -o decoded
grep -rE "sk-|sk_live_|sb_secret_|AKIA" decoded

Those patterns catch some well-known key formats: sk- for many AI providers, sk_live_ for Stripe live secret keys, sb_secret_ for Supabase secret keys and AKIA for AWS access key IDs. They do not catch everything, and binary files such as Flutter's libapp.so or a Hermes bundle need strings run over them first:

strings decoded/lib/arm64-v8a/libapp.so | grep -E "sk-|sb_secret_|AKIA"

Legacy Supabase keys are JWTs: long strings starting eyJ, with the role encoded inside. Paste any you find into a JWT decoder; if the payload says "role": "service_role", it is the secret one.

What should I do if I find one?

  1. Rotate it first. Every copy of the build already out there, installed on phones or saved by anyone who downloaded it, still has the old key. Removing it from the next build does not take it back.
  2. Move the call behind your server. Your app calls your backend (or a serverless function); your backend holds the secret and calls the provider. The app never sees it.
  3. Restrict what stays in the app. For keys that must be in the client, limit them to your app and to the services they are for, and protect the data behind them with the provider's access rules.

Leaked keys are one item on the pre-launch checklist. The rest is what Google checks: target API level, permissions and the Data safety form.

Sources

Next steps

Still need testers? Get 12 testers for your closed test through a free test-for-test exchange - you test another developer's app, they test yours, and every opt-in is verified.

Common questions

Can someone really get API keys out of my APK?
Yes. An APK is a zip file, and free tools such as apktool and jadx turn it back into readable resources and code. Obfuscation renames classes and methods, but string values like keys stay as they are.
Is my Firebase API key a leak?
Not by itself. Firebase says keys restricted to Firebase services are OK to include in code, because Security Rules and App Check, not the key, protect your data.
I shipped a secret key. Is deleting it from the next build enough?
No. Every copy of the old build still contains it, so rotate the key first, then move the call that needs it to your server.

Apps currently in closed testing

Real developers running the test described above. Test one, and get testers for your own app back.

Closed testing

In Between is a free card game. Join the group, opt in, install, open it and play a hand. Keep it 14 days. Not available in South Korea. I test your app back the same day.

Games

Available in all countries

Open to testers · 14-day test

Closed testing

# BAYAA — Closed Testing: Instructions for Testers Thank you for participating in the BAYAA (بياع) closed testing program. BAYAA is a Mauritanian marketplace designed to connect customers with shops, restaurants, pharmacies, hotels, and service providers. ## 1. What testers are expected to do - Install BAYAA through the official Google Play closed-testing link. - Keep the app installed throughout the 14-day testing period. - Open and use the app regularly during the testing period. - Create an account and test registration and login. - Browse available shops, products, and services. - Test search and navigation. - Test merchant features if you have a merchant account. - Check WhatsApp contact options where available. - Report bugs, errors, confusing screens, and suggestions. ## 2. What feedback should you provide? Please tell us: - What worked correctly? - What did not work? - Were any pages slow or difficult to use? - Did you experience crashes or unexpected errors? - What features would you like us to improve? Honest feedback is very important. You do not need to give positive feedback if you encounter a problem. ## 3. Important testing rules - Use the app with your own tester account. - Do not share your login credentials. - Do not enter real payment or sensitive personal information. - Do not make fake purchases or transactions. - Do not uninstall the app during the testing period unless instructed. - Keep your Google Play testing enrollment active. ## 4. Reporting problems Send your feedback and screenshots of errors to the BAYAA development team. Thank you for helping us improve BAYAA and prepare it for its official launch in Mauritania. **BAYAA — بياع | Supporting Mauritanian Businesses**

Shopping

Available in all countries

Open to testers · 14-day test

Closed testing

PocketLedger helps you know your money and own your month — without handing your financial life to anyone. Everything stays on your phone. There is no account to create, no bank login, no SMS reading and no internet access at all. PocketLedger works fully offline. TRACK EVERY RUPEE (OR DOLLAR, EURO, POUND) • Add income and expenses in seconds, with category, account, date, merchant and notes • Mark refunds so they reduce your spending instead of counting as income • Search by merchant or note, filter by type, and tap any category to see its transactions for the month • INR, USD, EUR and GBP supported — amounts in different currencies are never mixed or converted SEE YOUR MONTH AT A GLANCE • Net cash flow, total income and total expenses for any month • Spending by category with an interactive chart • Recent transactions and account balances on one screen BUDGETS THAT KEEP YOU HONEST • Set a monthly limit for any category • See what you have spent, what is left, and when you go over ALL YOUR ACCOUNTS • Cash, bank accounts, UPI, credit cards and wallets • Pick from popular banks (SBI, HDFC, ICICI, Axis, Kotak and many more) and UPI apps, or type any name • Live balance for every account NOTHING IS EVER LOST • Every transaction keeps a full version history: see exactly what changed, when • Deleted transactions can be restored • An activity log records every add, edit, delete and setting change PRIVATE BY DESIGN • No sign-up, no ads, no tracking, no analytics • No internet permission — your data physically cannot leave the app • Not backed up to the cloud PocketLedger is a personal budgeting and expense-tracking tool. It does not offer loans, payments, banking or investment services and does not connect to any bank. Made by Technopreneurs Technolabs.

Finance

Available in all countries

Open to testers · 14-day test

May we use analytics and ad measurement? Analytics (Vercel, and Ahrefs on our public pages) count page views without cookies. Ad measurement lets Google's tag on our public pages see which visits came from our Google ads, using a Google cookie. The site works the same either way. Cookie Policy · How Google uses data ·