使用ProGuard时GooglePlaces不起作用 [英] GooglePlaces doesn't work when using proguard

查看:202
本文介绍了使用ProGuard时GooglePlaces不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用googlePlaces和谷歌地图的API在我的Andr​​oid应用程序,一切工作正常。当启用Proguard的,谷歌地图是工作正常,但谷歌的地方不起作用,它返回我所有的搜索请求没有结果。看到日志后,我发现code的一部分不工作:

I use googlePlaces and google Map APIs in my android application, all work fine. When I enable Proguard, Google Map is working fine but Google Places doesn't work, It returns no result for all my search requests. After seeing the logs, I find out the part of code that doesn't work :

try {

        HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT);
        HttpRequest request = httpRequestFactory
                .buildGetRequest(new GenericUrl(PLACES_SEARCH_URL));
        request.getUrl().put("key", API_KEY);
        request.getUrl().put("location", _latitude + "," + _longitude);
        request.getUrl().put("radius", _radius); // in meters
        request.getUrl().put("sensor", "false");
        if(types != null)
            request.getUrl().put("types", types);

        PlacesList list = request.execute().parseAs(PlacesList.class);
        // Check log cat for places response status
        Log.d("Places Status", "" + list.status);
        return list;

    } catch (HttpResponseException e) {
        Log.e("Error:", e.getMessage());
        return null;
    }

这code返回null与ProGuard的版本,并返回与普通版的结果。

This code returns null with the proguard version, and returns a result with the normal version.

我试图保持与这样googlePlaces工作的所有类:

I tried to keep all the classes that working with googlePlaces like this :

-keep public class com.example.android.mapexample.GooglePlaces
-keep public class com.example.android.mapexample.Place
-keep public class com.example.android.mapexample.PlaceDetails
-keep public class com.example.android.mapexample.PlacesList

但它不工作。 :/我不知道什么是错

But it doesn't work. :/ I don't know what is wrong.

ProGuard的,谷歌的API-client.txt http://textuploader.com/?p = 6和ID = TAEQI

proguard-google-api-client.txt http://textuploader.com/?p=6&id=TAEQI

proguard的-project.txt http://textuploader.com/?p=6&id = HFbTF

proguard-project.txt http://textuploader.com/?p=6&id=HFbTF

感谢您的帮助。

推荐答案

保持序列化类后解决了问题至极使用谷歌地图API

Solved the issue after keeping Serializable classes wich use google map API

-keepnames class * implements java.io.Serializable

-keepclassmembers class * implements java.io.Serializable {
     static final long serialVersionUID;
     private static final java.io.ObjectStreamField[] serialPersistentFields;
     !static !transient <fields>;
     !private <fields>;
     !private <methods>;
     private void writeObject(java.io.ObjectOutputStream);
     private void readObject(java.io.ObjectInputStream);
     java.lang.Object writeReplace();
     java.lang.Object readResolve();
 }

这篇关于使用ProGuard时GooglePlaces不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆