Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Google New Places API-您的应用程序包含公开的Google云平台_Java_Android_Security - Fatal编程技术网

Java Google New Places API-您的应用程序包含公开的Google云平台

Java Google New Places API-您的应用程序包含公开的Google云平台,java,android,security,Java,Android,Security,您的应用程序包含公开的Google Cloud Platform(GCP)API密钥,类: MainActivity->onCreate 有关如何解决此问题,请参阅以下文章: 在实现新的GooglePlayStore API后,我从我的GooglePlayStore控制台收到此警报。我还使用SHA密钥对API密钥添加了限制。我使用了演示项目中的同一行 (第32行) 我的代码 String apiKey = getResources().getString(R.string.google

您的应用程序包含公开的Google Cloud Platform(GCP)API密钥,类:

MainActivity->onCreate
有关如何解决此问题,请参阅以下文章:

在实现新的GooglePlayStore API后,我从我的GooglePlayStore控制台收到此警报。我还使用SHA密钥对API密钥添加了限制。我使用了演示项目中的同一行

(第32行)

我的代码

String apiKey = getResources().getString(R.string.google_api_key);

if (!Places.isInitialized()) 
Places.initialize(getApplicationContext(), apiKey);

这些行用于导致此问题的活动中。我需要知道如何解决这个问题。因为Google new places API也是我的要求,所以我无法避免在代码中使用这些行。

问题是您直接将Google API密钥保存在
strings.xml
中。所以,任何人都可以很容易地得到你的密钥并使用它,如果他们提取了你的apk文件,即使你使用了proguard,它也帮不了你

这些是您可以采取的帮助最小化API密钥暴露的步骤

  • 通过发出请求从服务器获取Api密钥。该api应仅适用于应用程序中的授权用户。当然,即使这样也不是100%安全的,但它比在应用程序中简单地保留api密钥要好
  • 定期重新生成API密钥。通过单击每个键的“重新生成键”,可以从页面重新生成API键。然后,更新应用程序以使用新生成的密钥。生成替换密钥后,旧密钥将继续工作24小时
  • 为API键添加限制,请查看有关如何操作的部分

在另一侧使用相同的apiKey时出现问题。只需重新生成此API密钥。您已经尝试过此操作,即使对于新的API密钥也是一样的问题。请检查此链接,它将帮助您,谢谢!已经添加了限制。我将从服务器获取密钥并进行检查。