today:
154
yesterday:
242
Total:
1,004,312

Google Map

admin 2017.05.29 13:45 Views : 21

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ivan.pruebamaps">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">


<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="@string/google_maps_key" />

<activity
    android:name=".MapsActivity"
    android:label="@string/title_activity_maps">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
</application>

    </manifest>

I have a valid key in @string/google_maps_key.

The mainActivity it's untouched, the same as it's created in android studio.

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}


@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // Add a marker in Sydney and move the camera
    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}

The same happens with the layout file activity_maps:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.ivan.pruebamaps.MapsActivity" />

This is my gradle file if that helps :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.ivan.pruebamaps"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.google.android.gms:play-services-maps:10.2.0'
    testCompile 'junit:junit:4.12'
}
No. Subject Author Date Views
48 Website icon admin 2017.09.16 958
47 Android Application Development admin 2017.07.28 909
46 Load an ad admin 2017.07.21 1134
45 Add AdView to the layout admin 2017.07.21 1609
44 Import the Mobile Ads SDK admin 2017.07.21 1084
43 AdMob - Import the Mobile Ads SDK admin 2017.07.21 196
42 Image Center admin 2017.07.21 224
41 US1800s admin 2017.07.03 215
40 Symbols And Holidays admin 2017.07.03 213
39 Rights And Responsibilities admin 2017.07.03 191
38 Recent American History admin 2017.07.03 215
37 Geography admin 2017.07.03 202
36 Colonial Period And Independence admin 2017.07.03 209
35 System of Government admin 2017.07.03 213
34 Principles of American Democracy admin 2017.07.02 189
33 package com.solatoz.joseph.uscitizenshiptest; admin 2017.07.01 222
32 Contact Layout admin 2017.06.06 339
31 map api admin 2017.06.04 1273
30 Manifest admin 2017.06.04 246
29 Custom Swipe admin 2017.06.04 215