I want to use Google Maps in Fragment to show current location of user but before that I wanted just to show map. When I tested I have error as in the picture. What the best way to add Google Map API V2 and whats the reason to error?
fragment.xml
<fragment
android:id="@+id/googleMap"
android:layout_width="wrap_content"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
Fragment.java
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
GoogleMap mGoogleMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.googleMap)).getMap();
}
Manifect file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="www.smartavenue.com.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<!--meta-data is in the application-->
<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 key"/>
In build.gramble I added: compile 'com.google.android.gms:play-services:6.5.+'
Error :
请尝试以下操作: Google Map API V2演示
The problem is in this line :
Multiple dex file define Lcome/google/ads/Adrequest
you have two library in your gradle file which both use AdRequest library In your gradle file, check and clean the conflict libraries.
try building with --debug or --stacktrace to see the exact libraries which have conflicts
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.