0

I am new to this forum and in general in android development. I wish to help solve a problem that I have when running the app. The app I'm developing now is based on an activity of google maps. I've done all steps as creating credentials in google api developers and copy the key to xml and manifest. When I run the app I get this error:

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

What I'm trying for now is just to run the app and show me the google maps

This is 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>

This is the manifest:

   <?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>

This is 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));
}

}

Please help me to resolve this error.

enter image description here

enter image description here

enter image description here

techraf
  • 59,327
  • 25
  • 171
  • 185

2 Answers2

4

The problem is that you have more than one XML header or noise before one.

The typical start of an XML doc...

<?xml version='1.0'?>

looks like a PI, but isn't. If you have an extra, or if you have anything other than a BOM before one, that's the error you'll get.

Atman Bhatt
  • 1,245
  • 8
  • 14
0

I also faced the same problem in one of my android projects.

in my case, it is coming from the AndroidManifest.xml. because I added

<?xml version="1.0" encoding="utf-8"?>

in the starting of the file

this line should not be there in the file . and I resolve it by removing the line.

In your case also you have the line in the AndroidManifest.xml file. So remove it. I think it will solve your problem.

ujjal das
  • 761
  • 9
  • 14