How to obfuscate API KEYS in AndroidManifest Android

谁说我不能喝 提交于 2021-02-07 10:54:59

问题


I discovered ProGuard and I managed to get my code obfuscated. It works. Amazing tool.

But what ProGuard didn't obfuscate is the AndroidManifest.xml. I have a Google Maps API Key in my Manifest.

I "secured" this API KEY in Google Developer Console using my package name and SHA-1 fingerprint.

Is it recommended to obfuscate the api key in Manifest anyway? If so, how can I achieve this with ProGuard?


回答1:


  1. Put your google key into .xml file. Never place restricts strings into AndroidManifest file
  2. Try using Dexguad

On your Dexguard file, use the commands bellow
-encryptassetfiles res/values/**
(if you are using gradle job to get your environment parameters)
-encryptstrings class my.package.Environment.class

regards.



来源:https://stackoverflow.com/questions/46475140/how-to-obfuscate-api-keys-in-androidmanifest-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!