i don't speak english, but...
i'm making android app uses gmaps v2. in debug mode, when lunch release app, maps code doesn't execute!
i'm sure release apikey setted (i set in src/release/values/google_maps_api.xml , apikey doesn't have restriction), , because if set minifyenabled = false in release build type, works!, think it's problem proguard...
i try combinations of next proguard rules nothing...
-keep class com.google.** {*;} -keep class com.hawk.angela.home.activities.mapfragment { *; } -keep class com.google.android.gms.maps.** { *; } -keep interface com.google.android.gms.maps.** { *; } -keep class * extends java.util.listresourcebundle { protected object[][] getcontents(); } -keepattributes innerclasses -dontoptimize -keep public class * extends android.app.activity -keep public class * extends android.app.fragment -keep public class * extends android.support.v4.app.fragment # maps api uses custom parcelables. # use rule (which broader standard recommended one) # avoid obfuscating them. -keepclassmembers class * implements android.os.parcelable { static *** creator; } # maps api uses serialization. -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(); }
moreover, console doesn't return exception
the map initialization in fragment:
mapview mapview = (mapview) rootview.findviewbyid(r.id.mapview); bundle mapstate = (savedinstancestate != null) ? savedinstancestate.getbundle("mapstate") : null; mapview.oncreate(mapstate); mapview.onresume(); // needed map display mapview.getmapasync(new onmapreadycallback() { @override public void onmapready(googlemap mmap) { googlemap = mmap; googlemap.setmaxzoompreference(maxzoom); // ... } });
can me please? @ least have find problem...
thanks!!
edit: androidmanifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.enzonotario.app"> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.change_wifi_state" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.send_sms" /> <uses-permission android:name="android.permission.read_contacts" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.camera" /> <uses-permission android:name="android.permission.vibrate" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.location.network" android:required="false" /> <uses-feature android:name="android.hardware.location.gps" android:required="false" /> <!-- gcm permissions --> <uses-permission android:name="com.google.android.c2dm.permission.receive" /> <uses-permission android:name="android.permission.wake_lock" /> <!-- pusher service --> <uses-permission android:name="android.permission.receive_boot_completed" /> <!-- storage --> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.read_external_storage" /> <application android:name=".app" android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:largeheap="true" android:theme="@style/apptheme"> <meta-data android:name="database" android:value="app.db" /> <meta-data android:name="version" android:value="2" /> <meta-data android:name="query_log" android:value="false" /> <meta-data android:name="domain_package_name" android:value="com.enzonotario.app" /> <meta-data android:name="com.enzonotario.app.utils.glideconfigurationmodule" android:value="glidemodule" /> <meta-data android:name="com.google.android.geo.api_key" android:value="aizasyaqrp3zqzc9gohs3elhs7al0quo6wqowz8" /> <!-- pusher's fcm listeners , services --> <service android:name="com.pusher.android.notifications.fcm.fcmmessagingservice"> <intent-filter> <action android:name="com.google.firebase.messaging_event" /> </intent-filter> </service> <service android:name="com.pusher.android.notifications.fcm.fcminstanceidservice"> <intent-filter> <action android:name="com.google.firebase.instance_id_event" /> </intent-filter> </service> <service android:name=".syncservice" android:exported="false" /> <receiver android:name=".gps.receivers.gpslocationreceiver"> <intent-filter> <action android:name="android.location.providers_changed" /> <category android:name="android.intent.category.default" /> </intent-filter> </receiver> // many activities </application> </manifest>
google_maps_api.xml (release)
<resources> <!-- todo: before release application, need google maps api key. this, can either add release key credentials existing key, or create new key. note file specifies api key release build target. if have set key debug target debug signing certificate, need set key release certificate. follow directions here: https://developers.google.com/maps/documentation/android/signup once have key (it starts "aiza"), replace "google_maps_key" string in file. --> <string name="google_maps_key" templatemergestrategy="preserve" translatable="false"> aizasyaqrp3zqzc9gohs3elhs7al0quo6wqowz8 </string> </resources>
the api key google maps must explicitly set-up in androidmanifest.xml work.
for debug mode can set-up in google_maps_api.xml release build must in androidmanifest.xml
e.g.
<meta-data android:name="com.google.android.geo.api_key" android:value="<your api key here>"/>
i create 2 keys when this. 1 debug , 1 release. necessary because sha debug different release , need create 2 separate api keys each.
so androidmanifest.xml looks 1 below. when shift builds debug release or release debug, uncomment meta-data.
<!-- development/debug google maps api key --> <!--<meta-data android:name="com.google.android.geo.api_key" android:value="@string/google_maps_key"/> --> <!-- release google maps api key --> <meta-data android:name="com.google.android.geo.api_key" android:value="<my api key here>"/>
Comments
Post a Comment