У меня есть приложение для Android, которое я делаю и пытаюсь использовать карты Google. Я добавил фрагмент карт и запустил его, чтобы посмотреть, как он выглядит, но он продолжает сбой, что я массировал?Приложение продолжает терпеть крах, пытаясь иметь Android Maps на моем приложении
Вот мой основной класс
package germanclub.blundenbusroute.co.za;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class Main extends Activity implements OnMapReadyCallback {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapFragment mapFragment = (MapFragment)getFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.addMarker(new MarkerOptions().position(new LatLng(-33.975449, 25.529952)).title("German Club Oktoberfest"));
}
}
Вот мой Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="germanclub.blundenbusroute.co.za"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="21"/>
<application android:label="Oktoberfest Shuttle Service" android:icon="@drawable/germanclubcrest" android:theme="@android:style/Theme.Dialog">
<activity android:name="Main"
android:label="Oktoberfest Shuttle Service">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Вот мой Layout File
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/lblwelcome" android:layout_gravity="center_horizontal" android:text="@string/welcome"
android:textAlignment="center" android:layout_marginLeft="63dp"
android:layout_alignParentTop="false" android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/lblpickuppoint"
android:text="@string/pickuppoint" android:layout_marginLeft="0dp"
android:layout_marginTop="42dp"
android:layout_alignEnd="@+id/lblwelcome" android:layout_centerHorizontal="true" android:paddingTop="50dp"
android:paddingBottom="15dp"/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:orientation="horizontal" android:layout_marginLeft="0dp"
android:layout_below="@+id/lblpickuppoint" android:layout_alignParentStart="false"
android:layout_alignParentEnd="false" android:layout_centerHorizontal="true" android:id="@+id/radioGroup">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NMMU"
android:id="@+id/rdbNMMU" android:checked="true"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5 Ways Spar"
android:id="@+id/rdb5Ways" android:checked="false"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sherwood Spar"
android:id="@+id/rdbStadium" android:checked="false"/>
</RadioGroup>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="350dp"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
Можете ли вы разместить свой логарифм? Вы зарегистрировали свою карту? Я не вижу ключа в манифесте. – jekeyeke
, пожалуйста, напишите логически, чтобы быть более ясными с вашим вопросом, также нет никаких разрешений в вашем манифесте, необходимых для отображения карт. – Aakash
Привет, извините, я снова прочитал свой код, извините, очень глупая ошибка не получить ключ для API карт google – user3406096