Maybe I am missing something here, but I am not able to use the new Maps only dependency in Play Services 6.5
I get the following exception:
java.lang.NoSuchFieldError: No static field MapAttrs of type
[I in class Lcom/google/android/gms/R$styleable; or its superclasses
(declaration of 'com.google.android.gms.R$styleable' appears in
/data/app/com.kaching.merchant.dev1-1/base.apk)
at com.google.android.gms.maps.GoogleMapOptions
.createFromAttributes(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment
.onInflate(Unknown Source)
Manifest:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my-awesome-key"/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
Gradle file:
compile 'com.google.android.gms:play-services-maps:6.5.+'
compile 'com.android.support:support-v4:21.0.2'
Layout:
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Is this broken or am I doing something wrong?
The full bundle pushes me over the dex limit and I would prefer not to use multidex
Updating your Google Repository to version 15
via the SDK Manager should resolve the issues and eliminate the needs for the workarounds. A project clean is required.
This is also mentioned in issue 7432.
Interim solution
replace the xml map fragment with a FrameLayout container
<FrameLayout
android:id="@+id/map_container"
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="0dp"
/>
<!--<fragment android:id="@+id/map"-->
<!--android:layout_weight="2"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="0dp"-->
<!--android:name="com.google.android.gms.maps.SupportMapFragment"/>-->
Create the fragment in code and replace the container
SupportMapFragment supportMapFragment = SupportMapFragment.newInstance();
getSupportFragmentManager().beginTransaction().replace(R.id.map_container,supportMapFragment).commit();
//this you should do anyway
supportMapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
//setup map - optional
UiSettings settings = googleMap.getUiSettings();
settings.setCompassEnabled(false);
settings.setZoomControlsEnabled(false);
settings.setAllGesturesEnabled(true);
settings.setMyLocationButtonEnabled(true);
}
});
Please note that the above was done in 'onCreate' in an activity without any other fragments, so make sure you adapt the transaction to your lifecycle and logic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With