简体   繁体   中英

Can't make google maps v2 work with min sdk 8

Hello, I've already read a lot of responses on how to make maps work with lover than 11sdk, but i did everything and i still can't make it work. My minsdk is set to 8. I always get error like this:

Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library com.google.android.gms:play-services:6.1.71`

I can't change my min sdk to 9 or 11, because i desperatedly need it to be 8. I already tryed changing to supportmapfragment and so on. Here's my code: fragment_maps.xml

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

<fragment
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment"/>

</RelativeLayout>

maps.java

package com.miesto.meniu;

import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.*;
import android.os.Build;
import com.google.android.gms.maps.SupportMapFragment;
import android.widget.Toast;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.text.SimpleDateFormat;


public class maps extends FragmentActivity {


Fragment fragment = getSupportFragmentManager().findFragmentById(
        R.id.mapView);
SupportMapFragment mapFragment = (SupportMapFragment) fragment;
GoogleMap mMap = mapFragment.getMap();

@Override
protected void onCreate(Bundle savedInstanceState) {
    createMapView();
    addMarker();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }
}
GoogleMap googleMap;

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.maps, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_maps, container, false);
        return rootView;
    }
}

/**
 * THIS WONT WORK SO I JUST COMMENTED IT BUT LEFT IT IF ILL NEED IT LATER
 */
private void createMapView(){
    /**
     *  Catch the null pointer exception that
     * may be thrown when initialising the map

     try {
     if(null == googleMap){

            HERE I GET ERROR THAT getfragmentmanager and findfragmentbyid NEED minsdk 11
            googleMap = ((MapFragment) getFragmentManager().findFragmentById( 
                    R.id.mapView)).getMap();

            if(null == googleMap) {
                Toast.makeText(getApplicationContext(),
                        "Klaida rodant zemelapi", Toast.LENGTH_SHORT).show();
            }
        }
    } catch (NullPointerException exception){
        Log.e("miesto.meniu", exception.toString());
    }
     */
}

/** -------------------------------
 *
 */
/**
 * Adds a marker to the map
 */
private void addMarker(){

    /** Make sure that the map has been initialised **/
    if(null != googleMap){
        googleMap.addMarker(new MarkerOptions()
                        .position(new LatLng(0, 0))
                        .title("Marker")
                        .draggable(true)
        );
    }
}
}

any help would be greatly appreciated

google-play-services_lib manifest change android:minSdkVersion 8

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gms"
android:versionCode="6171000"
android:versionName="6.1.71-000" >

<uses-sdk android:minSdkVersion="9" />

<application />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM