前提・実現したいこと
android studio で google Mapを表示したい
発生している問題・エラーメッセージ
E/ServiceManager: try to find service failed, not allowed access from isolated processes.
nsure that the "Google Maps Android API v2" is enabled. Ensure that the following Android Key exists: API Key: 取得したapiキーが表示されていました Android Application (<cert_fingerprint>;<package_name>):
該当のソースコード
ソースコード
前提・実現したいこと
google Mapsが表示されるようにしたい
該当のソースコード
java
1import android.support.v4.app.FragmentActivity; 2import android.os.Bundle; 3 4import com.google.android.gms.maps.CameraUpdateFactory; 5import com.google.android.gms.maps.GoogleMap; 6import com.google.android.gms.maps.OnMapReadyCallback; 7import com.google.android.gms.maps.SupportMapFragment; 8import com.google.android.gms.maps.model.LatLng; 9import com.google.android.gms.maps.model.MarkerOptions; 10 11public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 12 13 private GoogleMap mMap; 14 15 @Override 16 protected void onCreate(Bundle savedInstanceState) { 17 super.onCreate(savedInstanceState); 18 setContentView(R.layout.activity_maps); 19 // Obtain the SupportMapFragment and get notified when the map is ready to be used. 20 SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 21 .findFragmentById(R.id.map); 22 mapFragment.getMapAsync(this); 23 } 24 25 26 /** 27 * Manipulates the map once available. 28 * This callback is triggered when the map is ready to be used. 29 * This is where we can add markers or lines, add listeners or move the camera. In this case, 30 * we just add a marker near Sydney, Australia. 31 * If Google Play services is not installed on the device, the user will be prompted to install 32 * it inside the SupportMapFragment. This method will only be triggered once the user has 33 * installed Google Play services and returned to the app. 34 */ 35 @Override 36 public void onMapReady(GoogleMap googleMap) { 37 mMap = googleMap; 38 39 // Add a marker in Sydney and move the camera 40 LatLng sydney = new LatLng(-34, 151); 41 mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); 42 mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); 43 } 44}
xml
1<resources> 2 <!-- 3 TODO: Before you run your application, you need a Google Maps API key. 4 5 To get one, follow this link, follow the directions and press "Create" at the end: 6 7 (linkが貼ってありました) 8 9 You can also add your credentials to an existing key, using these values: 10 11 Package name: 12 13 14 SHA-1 certificate fingerprint: 15 16 17 Alternatively, follow the directions here: 18 https://developers.google.com/maps/documentation/android/start#get-key 19 20 Once you have your key (it starts with "AIza"), replace the "google_maps_key" 21 string in this file. 22 --> 23 <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"></string> 24</resources> 25
試したこと
API keyを記述しました
補足情報(FW/ツールのバージョンなど)
API key 以外に何も記述していません。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。