Java 我需要谷歌地图API的帮助
但我的android应用程序还有另一个问题 我开发了一个非常基本的应用程序,它包含一个活动并显示GoogleMaps(我使用GoogleMapsAPI)。编译结束时没有错误,我也生成了apk,没有任何问题,但是当我在不同的设备上运行我的应用程序时,只会在页面下方显示一个带有谷歌标志的空白页面Java 我需要谷歌地图API的帮助,java,android,google-maps,Java,Android,Google Maps,但我的android应用程序还有另一个问题 我开发了一个非常基本的应用程序,它包含一个活动并显示GoogleMaps(我使用GoogleMapsAPI)。编译结束时没有错误,我也生成了apk,没有任何问题,但是当我在不同的设备上运行我的应用程序时,只会在页面下方显示一个带有谷歌标志的空白页面 [![This the screenshot of my application][1]][1] package com.example.amine.bea_mapapp; public class
[![This the screenshot of my application][1]][1]
package com.example.amine.bea_mapapp;
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));
}
}
我的API密钥在这里
您的Google API密钥似乎有问题。你现在用的是什么钥匙
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="My API key is here" />
如果仍在解决这个问题,请使用从您的计算机生成的密钥库生成新的Google Map API密钥,并使用新的Map API密钥构建apk。我确信它将在所有设备上运行。您首先需要检查该设备中的谷歌帐户是否已登录
第二件事是检查测试设备中的内置映射是否正常工作。因为google map可以从现有的地图应用程序和您的google帐户访问某些服务。?在日志中查找与api密钥相关的错误您生成了哪个apk文件?签名apk或调试apk..?是的,这些内容对于android应用程序中的地图是必需的。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.amine.bea_mapapp">
<permission android:name="com.androidcom.example.amine.bea_mapapp.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.androidcom.example.amine.bea_mapapp.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.androidcom.example.amine.bea_mapapp.providers.gsf.permission.READ_GSFREVICES"/>
<uses-feature android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="My API key is here" />
<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>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="My API key is here" />