私はアンドロイドアプリで地図を表示しようとしています。私はいくつかの問題を抱えています。 私はseveralsチュートリアルに従っていますが、まだ結果がありません。 私はsdkマネージャからgoogle playサービスをダウンロードし、google_play_services_libを正しくインポートしました。 私は、Google Apiコンソールから、私のpackagenameと私のSHA1を使ってGoogle Maps APIキーを作成しました。これはcmdを使って見つけました。また、ウィンドウ>設定>アンドロイド>ビルドでEclipseでも同じSHA1を得ました。正しい。 「=クラスに名前を付ける:MapFragmentはロードされません
は、だから、私は私がアンドロイドを変更した
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/textView1"
android:layout_centerHorizontal="true" />
ちょうど地図の断片を作成し、私のレイアウトファイルにこの
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemapprova"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<permission android:name="com.example.googlemapprova.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.googlemapprova.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<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-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my api key" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
ように私のマニフェストを設定しますcom.google.android.gms.maps.SupportMapFragment "チュートリアルのため
そして、私のメイン
package com.example.googlemapprova;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {
GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
// Loading map
initilizeMap();
initializeUiSettings();
initializeMapLocationSettings();
initializeMapTraffic();
initializeMapType();
initializeMapViewSettings();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onResume() {
super.onResume();
// initilizeMap();
}
private void initilizeMap() {
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(), "Sorry! unable to create maps", Toast.LENGTH_SHORT).show();
}
}
public void initializeUiSettings() {
googleMap.getUiSettings().setCompassEnabled(true);
googleMap.getUiSettings().setRotateGesturesEnabled(false);
googleMap.getUiSettings().setTiltGesturesEnabled(true);
googleMap.getUiSettings().setZoomControlsEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
}
public void initializeMapLocationSettings() {
googleMap.setMyLocationEnabled(true);
}
public void initializeMapTraffic() {
googleMap.setTrafficEnabled(true);
}
public void initializeMapType() {
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
public void initializeMapViewSettings() {
googleMap.setIndoorEnabled(true);
googleMap.setBuildingsEnabled(false);
}
}
私はこのコード私のアプリを使用していない場合、私は(チュートリアルからの私のメインのコードを持って、私はクラッシュしないように私のアプリを管理し、このように、ほんの少しそれを修正しましたクラッシュする)。 this is what i get モトローラモトg3電話を使って試してみました プレイストアから電話でaLogcatをダウンロードしようとしましたが、何も得られません。間違った方法で使用しています。 this is the tutorial i used the most
誰かが私のアプリ上の地図を表示するために私を助けることができますか?なぜそれが動作していないのかわかりません 私は現在ログキャッチを取得しようとしています
uはこれを読んで、https://developers.google.com/maps/documentation/android-api/start#the_maps_activity_java_fileを試すことができます – Raghavendra
SO [17469661](HTTP質問これでコードをチェックしてみてください/stackoverflow.com/questions/17469661/google-mapfragment-not-working-in-android)および[15703245](http://stackoverflow.com/questions/15703245/google-maps-fragment-doesnt-load)があればあなたを助けられる。また、Google Playサービスライブラリプロジェクトを適切に参照していることを確認してください。 – KENdi
あなたは皆、私は日食の代わりにアンドロイドスタジオを使用しようとしたすべてのものは完璧に働いた。別のスタックオーバーフローの質問に誰かが日食が正しくメタデータタグを読み取るcouldntの語りました。だから今、私は疑問に思ってアクティビティ・ノード – Lucas