【问题标题】:Android Google Place Picker working in Signed APK but not working in Live appAndroid Google Place Picker 在签名的 APK 中工作,但在 Live 应用程序中不工作
【发布时间】:2017-09-19 18:28:51
【问题描述】:

我有一个使用 Google Place Picker 的应用程序。我面临一个非常奇怪的问题。当我使用我的应用程序的密钥库创建签名的 APK 时,Place Picker 运行良好。我通过 Google PlayStore 上传的同一个 APK。当我打开那个地方选择器时,它会自动关闭。我已经在网上和 SO 中阅读了很多 cmets。但我无法确定为什么它在签名的 APK 中运行良好,而在 Google PlayStore 上的同一个 APK 无法运行。

当我检查 Google PlayStore 的 LIVE 应用程序日志时,它给出了这样的错误:

Volley : [198] BasicNetwork.performRequest: Unexpected response code 403
for https: //www.googleapis.com/placesandroid/v1/search?key=MY_KEY/ ? V / ConnectivityManager : isActiveNetworkMetered() returns: true
/ ? E / AsyncOperation : serviceID = 65, operation = SearchPlaces
OperationException[Status {
 statusCode = PLACES_API_INVALID_APP, resolution = null
}]

我已经在我的 Google 开发者控制台中检查了我的密钥是否相同。我还检查了我从 KeyStore 文件创建的 SHA。一切都很好(否则,如果那里有任何问题,它也不会在签名 APK 中工作)。

这是我从我的活动中调用 Place Picker 的方式

int PLACE_PICKER_REQUEST = 999;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);

这是我的 AndroidManifest.xml 文件,其中我在元数据中提供了我的 API 密钥,该密钥位于应用程序标签中。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example" >
    // ALL PERMISSIONS ARE HERE
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data            
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/MY_KEY" />
    </application>
</manifest>

我删除了自动生成的“release/values/google_maps_api.xml”文件。正如我已经在 string.xml 中提到了我的 API 密钥,所以我从发布包中删除了整个值包。

谁能告诉我这是怎么回事?

【问题讨论】:

  • 我已经参考了您给定的链接。但是不明白为什么Google 创建一个.xml 文件ane 的时候是在哪里创建的呢?还有我必须做什么才能停止创建这个新的 xml 文件?

标签: android google-maps key google-places-api developer-console


【解决方案1】:

经过几天的投入时间来寻找解决此问题的方法。最后我得到了解决方案。是因为Google Play App Signing .

使用 Google Play 应用签名:您使用上传密钥对应用进行签名。 然后,Google 会验证并删除上传密钥签名。最后, Google 使用您提供的原始应用签名密钥对应用重新签名 并将您的应用交付给用户。

因此,当我为“Google Places API for Android”创建 API 密钥时,我使用我的包名称和签名 APK 密钥库的 SHA-1 限制了该密钥。

现在它在“上传证书”下并且没有使用,因为我必须将我的 App Singing Certificate 的 SHA-1 传递给 Google Developer Console。之后,我的 Google PlayStore 的实时应用程序的 Google PlacePicker 运行良好。

【讨论】:

  • 天才!太糟糕了,谷歌让这些信息变得如此难以“找到并创造开发者的噩梦”!太感谢了!! @Ronak
  • 这就是为什么我回答了我自己的问题,这样其他人就不会花更多时间在上面了。谢谢@Sjd
  • 信不信由你,我再次回到这个线程来寻找你的解决方案!感谢您发布这个很棒的答案!
  • @Sjd 很高兴这篇文章再次对您有所帮助。为发帖 +1,以便其他人也能从中受益。
  • 即使添加了来自 google playstore 的登录密钥,问题仍然存在。
猜你喜欢
  • 2015-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-12
  • 2016-07-10
  • 2018-10-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多