问题描述
我已经在我的应用程序中实现了Google Maps(Google API).因此,我在应用程序中添加了ProGuard文件.添加Proguard文件后,地图没有打开,并显示了白色的空白屏幕.
I have implemented Google Maps (Google API) in my application. So I added ProGuard file inside my application. After adding the Proguard file, the map is not opening, and showing a white blank screen.
这是我的Proguard代码:
This is my Proguard code:
-keep class * implements com.google.android.gms.maps { *; }
-keep class com.google.android.gms.maps.** { *; }
-keep interface com.google.android.gms.maps.** { *; }
我已经尝试过了,但是没有用.
I have tried this, but it's not working.
推荐答案
Google Maps API
还使用其他一些东西,这些东西可能会在混淆过程中引起问题,例如自定义Parcelables和序列化.这些规则应该起作用:
The Google Maps API
uses some other stuff as well which can cause problems during obfuscation, like custom Parcelables and serialization. These rules should work:
-keepclassmembers class * implements android.os.Parcelable {
static *** CREATOR;
}
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
来源: https://github .com/googlemaps/android-samples/blob/master/ApiDemos/app/proguard-rules.pro
根据评论中的@Fakher:
According to @Fakher in the comments:
还请注意,您的API密钥必须正确,如果您请求了API密钥并将其添加到应用程序中,则Google仅向您显示可见的地图.
Also note that your API key needs to be correct, Google only show you a visible Map if you have requested an API key and added it in your application.
这篇关于如何使Google Maps处于混乱状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!