2015-06-26 4 views
0

Я пытаюсь создать приложение с Google Maps API V2 следуя этой обучающей программе: http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/Google Maps Android API V2 врезается

Я внимательно следил за этот учебник, но мое приложение сбой. Вот мой ManifestFile (у меня есть несколько действий)

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.philimon" 
android:versionCode="1" 
android:versionName="1.0" > 

<permission 
    android:name="com.example.philimon.permission.MAPS_RECEIVE" 
    android:protectionLevel="signature" /> 

<uses-permission android:name="com.example.philimon.permission.MAPS_RECEIVE" /> 

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="19" /> 

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

<!-- Required to show current location --> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

<!-- Required OpenGL ES 2.0. for Maps V2 --> 
<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" > 

    <!-- DEVELOPER'S LOADING SCREEN --> 
    <activity 
     android:name=".DevelopersSplashScreen" 
     android:label="@string/title_activity_developers_splash_screen" 
     android:screenOrientation="landscape" > 


    </activity>         <!-- END OF ACTIVITY --> 



    <!-- MONSTER ISLAND PHIL LOADING SCREEN --> 
    <activity 
     android:name=".PhilimonSplashScreen" 
     android:label="@string/title_activity_sample" 
     android:screenOrientation="landscape" > 
    </activity>              <!-- END OF ACTIVITY --> 


    <!-- MY HOME ACTIVITY SCREEN --> 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="landscape" > 
    </activity>              <!-- END OF ACTIVITY --> 




    <activity 
     android:name=".Home" 
     android:label="@string/title_activity_home" 
     android:screenOrientation="landscape"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

    </activity>               <!-- END OF ACTIVITY --> 

    <!-- Google Maps API Key --> 
    <meta-data 
     android:name="com.google.android.maps.v2.API_KEY" 
     android:value="AIzaSyCiwzjBd6Mx9Mp_tUXAezALDRnDG6kzIzo" /> 
</application> 

мой Xml расположение:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<fragment 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.MapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

мой Java файл:

package com.example.philimon; 

import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.MapFragment; 
import android.annotation.SuppressLint; 
import android.app.Activity; 
import android.os.Bundle; 
import android.support.v4.app.FragmentActivity; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.Window; 
import android.view.WindowManager; 
import android.widget.Toast; 


@SuppressLint("NewApi") 

public class Home extends Activity { 

// Google Map 
private GoogleMap googleMap; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    try { 
     // Loading map 
     initilizeMap(); 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 


} 

/** 
* function to load map. If map is not created it will create it for you 
* */ 
private void initilizeMap() { 
    if (googleMap == null) { 
     googleMap = ((MapFragment) getFragmentManager().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(); 
     } 
    } 
} 

@Override 
protected void onResume() { 
    super.onResume(); 
    initilizeMap(); 
} 


} 
+4

Не могли бы вы разместите ** LogCat **? –

ответ

3

Вы Бесполезный «Т добавить GMS версии мета-данные:

<application> 
    <meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version"/> 
    ... 
</application> 
+1

Одно замечание: Google Play Services 7.0 на самом деле не нужно добавлять это вручную: https://plus.google.com/+IanLake/posts/8ewDRqGUFyp –

+1

@ DanielNugent cool! Спасибо за info :) – Simas

+0

это сработало, спасибо :) теперь мое приложение продолжает мою активность в карте google, но у меня есть еще одна проблема. активность карты google вообще не отображает карту – dens14345

0

Это пример файла манифеста, который использует API v2 Google Google Maps для Android на Android Wear

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="your package name" > 

<!-- Mark this app as an Android Wear app. --> 
<uses-feature android:name="android.hardware.type.watch" /> 

<!-- Permissions and features required for the Android Maps API v2 --> 
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

<uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true"/> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.DeviceDefault" > 

    <!-- API key for the Android Maps API v2. The value is defined as a string resource. --> 
    <meta-data android:name="com.google.android.geo.API_KEY" 
       android:value="@string/google_maps_key"/> 

    <!-- Meta data required for Google Play Services --> 
    <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>