Jeferson.
Quando clico na opção de mapa, exibe a mensagem:
Agenda won't run unless update Google Play services. [UPDATE]
Sendo que habilitei no SDK Manager > SDK Tools > Google Play Services.
E o registro do aplicativo foi feito com sucesso, seguem as evidências do Google:
Chave de API criada
Transfira esta chave com o parâmetro key=API_KEY para usá-la no seu aplicativo.
Sua chave de API
AIzaSyBysqDgtwAHNS34hBxCHNA-AwZxDb16ZAE
Restrinja sua chave para evitar uso não autorizado na produção.
Chave de API
Esta chave de API pode ser usada neste projeto e com qualquer API compatível com ela. Para usar essa chave no seu aplicativo, transfira-a com o parâmetro key=API_KEY .
Data da criação
1 de nov de 2016 15:59:38
Criada por
vlconsultoria@ig.com.br (você)
Chave de API
AIzaSyBysqDgtwAHNS34hBxCHNA-AwZxDb16ZAE
Nome
Chave de API 1
Restrição de chave
Restringir uma chave é especificar quais websites, endereços IP ou aplicativos podem utilizá-la. Saiba mais
Nenhum
Referenciadores de HTTP (sites da Web)
Endereços IP (servidores da Web, cron jobs etc.)
Apps para Android
Apps para iOS
Restringir o uso de seus apps para Android (Opcional)
Adicione o nome do seu pacote e a impressão digital do certificado de assinatura SHA-1 para restringir o uso dos seus aplicativos para Android
Saiba mais Receba o nome do pacote do arquivo AndroidManifest.xml. Depois, use o comando a seguir para conseguir a impressão digital:
$ keytool -list -v -keystore mystore.keystore
Nome do pacote Impressão digital para certificação SHA-1
vlc.com.br.agenda.web 76:4B:B2:A2:1C:F9:C8:ED:8A:1D:18:C0:98:4F:F6:18:25:93:54:84
Adicionar nome do pacote e impressão digital
Nota: pode levar até cinco minutos para que as configurações sejam aplicadas
Salvar Cancelar
Chaves de API
Nome Data de criação Restrição Chave
Chave de API 1 1 de nov de 2016 App para Android AIzaSyBysqDgtwAHNS34hBxCHNA-AwZxDb16ZAE
Seguem os arquivos: google_maps_api, AndroidManifest, MapsActivity, build.gradle.
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=76:4B:B2:A2:1C:F9:C8:ED:8A:1D:18:C0:98:4F:F6:18:25:93:54:84%3Bvlc.com.br.agenda.web
You can also add your credentials to an existing key, using this line:
76:4B:B2:A2:1C:F9:C8:ED:8A:1D:18:C0:98:4F:F6:18:25:93:54:84;vlc.com.br.agenda.web
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyBysqDgtwAHNS34hBxCHNA-AwZxDb16ZAE</string>
</resources>
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".web.ListaAlunosActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".web.FormularioActivity"
android:label="@string/title_activity_formulario" />
<receiver android:name=".receiver.SMSReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<activity android:name=".web.ProvasActivity" />
<activity android:name=".web.DetalhesProvaActivity" />
<activity android:name=".web.ProvasTabletActivity" />
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBysqDgtwAHNS34hBxCHNA-AwZxDb16ZAE"/>
<activity
android:name=".web.MapsActivity"
android:label="@string/title_activity_maps"></activity>
</application>
</manifest>
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import vlc.com.br.agenda.R;
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);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@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));
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "vlc.com.br.agenda"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'}