2016-10-17 4 views
0

私はこのフォーラムや一般的なアンドロイド開発では初めてです。私は、アプリケーションを実行しているときに私が持っている問題を解決するのに役立ちます。私が開発しているアプリは、Googleマップの活動に基づいています。私はGoogle APIの開発者の資格情報を作成し、キーをXMLにコピーしてマニフェストとしてすべての手順を実行しました。私はアプリを実行すると、私はこのエラーを取得:エラーgoogle_maps_api.xml

<resources><string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">AIzaSyDtbq2HdPj5VpKCCvhj1vbuUaA1HIAz8Gg</string> 
<?xml version="1.0" encoding="utf-8" ?> 
<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    android:name="com.google.android.gms.maps.MapFragment" 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/></resources> 

Error: (2, 10) Error: The fate of the processing instruction that matches" [xX] [mM] [lL] "is not allowed. App: mergeDebugResources FAILED

私は今のところしようとしていることだけでアプリを実行すると、Googleは

これはgoogle_maps_api.xmlあるをマップ私を示すことです

これは明らかである:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="app.newproyect.santagadea.pierre.pruebaculinario" > 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <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="AIzaSyDtbq2HdPj5VpKCCvhj1vbuUaA1HIAz8Gg" /> 
     <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> 
</manifest> 

これはMapsActivity.javaある:

package app.newproyect.santagadea.pierre.pruebaculinario; 


import android.support.v4.app.FragmentActivity; 
import android.os.Bundle; 

import com.google.android.gms.maps.CameraUpdateFactory; 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.OnMapReadyCallback; 
import com.google.android.gms.maps.SupportMapFragment; 
import com.google.android.gms.maps.model.LatLng; 
import com.google.android.gms.maps.model.MarkerOptions; 

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 
private GoogleMap mMap; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.google_maps_api); 
    // 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); 
} 

@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)); 
} 

}

このエラーを解決するために私を助けてください。

enter image description here

enter image description here

enter image description here

+0

ここにあなたの「google_maps_api.xml」を投稿してください。 – Max

+0

あなたのイメージをコードで置き換え、その後エラーがあります。 –

+0

どのようにリソースタグファイルにフラグメントを配置できますか。 – YLS

答えて

0

問題は1の前に1つのXMLヘッダーやノイズよりも多くを持っていることです。

XMLドキュメントの典型的な開始...

<?xml version='1.0'?> 

は、PIのように見えますが、ではありません。余分なものがある場合や、BOM以外のものがある場合は、そのエラーが表示されます。

+0

私は質問で余分に表示されていません。あなたはどこを参考にしていますか? –

+0

xmlのリソースタグを削除し、APIをstring.xmlファイルに設定します –

+0

まず、「自分のコード」ではない第2に、strings.xmlも投稿に表示されていません –

関連する問題