Android:Google地图在我的设备上显示(Android 6.0),但不在nexus上显示(Android 6.0.1)

时间:2016-05-25 10:29:45

标签: java android google-maps

我正在开发一个Android项目,其中我有一些地图功能。它可以在我的手机上运行,​​但是当我尝试我的一个同事手机这是一个NExus并运行android 6.0.1时,他无法看到地图或任何标记。我还将它连接到USB调试,我在这两个设备上遇到的唯一警告/错误是GoogleSignature,抱怨它没有经过验证。

错误日志:

nchify V/GoogleSignatureVerifier: myproject signature not valid.  Found: 
                                                                                         RANDOM_DATA
05-25 11:51:21.552 29264-30085/myproject D/GoogleCertificatesImpl: Fetched 300 Google certificates
05-25 11:51:21.572 29264-30085/myproject V/GoogleSignatureVerifier: myproject signature not valid.  Found: RANDOM_DATA

05-25 11:51:22.549 29264-30047/myproject D/Volley: [2616] hj.a: HTTP response for request=<[ ] https://clients4.google.com/glm/mmap/api 0x99e6744e NORMAL 1> [lifetime=3750], [size=83], [rc=200], [retryCount=0]
05-25 11:51:22.551 29264-29264/myprojectg D/Volley: [1] gu.b: 3782 ms: [ ] https://clients4.google.com/glm/mmap/api 0x99e6744e NORMAL 1
05-25 11:51:22.549 29264-30047/myproject D/Volley: [2616] hj.a: HTTP response for request=<[ ] https://clients4.google.com/glm/mmap/api 0x99e6744e NORMAL 1> [lifetime=3750], [size=83], [rc=200], [retryCount=0]
05-25 11:51:22.551 29264-29264/myproject D/Volley: [1] gu.b: 3782 ms: [ ] https://clients4.google.com/glm/mmap/api 0x99e6744e NORMAL 1
05-25 11:51:28.796 29264-30048/myproject D/Volley: [2617] hj.a: HTTP response for request=<[ ] https://csi.gstatic.com/csi?s=maps_android_api&v=3&action=map_start_up&it=map_load.4554,on_create.1,on_resume.6,init.317&irt=4555,319,2420,318 0x4d844933 NORMAL 3> [lifetime=5644], [size=0], [rc=204], [retryCount=1]
05-25 11:51:28.805 29264-29264/myproject D/Volley: [1] gu.b: 5656 ms: [ ] https://csi.gstatic.com/csi?s=maps_android_api&v=3&action=map_start_up&it=map_load.4554,on_create.1,on_resume.6,init.317&irt=4555,319,2420,318 0x4d844933 NORMAL 3
05-25 11:51:32.124 29264-29285/myproject W/art: Suspending all threads took: 11.324ms

由于没有已知错误,我必须添加下面的大部分课程。

代码:

public class MapsActivity extends DrawerLoader {

 GoogleMap googleMap;
    SharedPreferences sharedPreferences;
    int locationCount = 0;

    private RestaurantServiceImpl restaurantService = new RestaurantServiceImpl();

    List<RestRestaurant> restRestaurantList = new ArrayList<>();

    GPSTracker gps;

    double longitude, latitude;
 String zoom;

    boolean firstClick = false;
    int restaurantId = 0;
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mapsact);
        set();
  SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        googleMap = fm.getMap();

        // Getting GoogleMap object from the fragment

        googleMap.getUiSettings().setMapToolbarEnabled(true);

        // Enabling MyLocation Layer of Google Map
        googleMap.setMyLocationEnabled(true);


        // Opening the sharedPreferences object
        sharedPreferences = getSharedPreferences("location", 0);

        // Getting number of locations already stored
        locationCount = sharedPreferences.getInt("locationCount", 0);


        // Getting stored zoom level if exists else return 0
         zoom = sharedPreferences.getString("zoom", "12");

        gps = new GPSTracker(MapsActivity.this);

        if (gps.canGetLocation()) {
            longitude = gps.getLongitude();
            latitude = gps.getLatitude();

            Double[] gpsArray = new Double[]{longitude,latitude};

            new getListOfRestaurantsForUser(this).execute(gpsArray);

            restRestaurantList = this.restaurantService.getRestaurantsByLocation(longitude, latitude);
        } else {
            gps.showSettingsAlert();
        }

        googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(Marker marker) {
                int restoId = Integer.valueOf(marker.getSnippet());

                if((!firstClick) && (restaurantId != restoId)){
                    firstClick = true;
                    restaurantId = restoId;
                    marker.showInfoWindow();
                    return false;
                }else {
                    firstClick = false;
                    restaurantId = restoId;
                    Intent intent = new Intent(MapsActivity.this, MenuCardList.class);
                    intent.putExtra("restaurantid", restoId);
                    startActivity(intent);
                    finish();
                    return true;
                }
            }
        });
    }

    private void drawMarker(LatLng point, String restaurantName, int restaurantId){
        // Creating an instance of MarkerOptions
        MarkerOptions markerOptions = new MarkerOptions();

        // Setting latitude and longitude for the marker
        markerOptions.position(point);
        markerOptions.snippet(String.valueOf(restaurantId));
        markerOptions.title(restaurantName);

        // Adding marker on the Google Map
       Marker marker = googleMap.addMarker(markerOptions);

        marker.showInfoWindow();
        googleMap.getUiSettings().setMapToolbarEnabled(true);

    }
}

build.gradle:

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.fasterxml.jackson.core:jackson-core:2.6.0'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.6.0'
    compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
    compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
    compile ('org.springframework.android:spring-android-auth:1.0.1.RELEASE'){
        exclude group :'org.springframework', module: 'commons-logging'
        exclude group :'org.springframework', module: 'spring-core'
        exclude group :'org.springframework', module: 'spring-web'
    }
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'commons-codec:commons-codec:1.9'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:22.2.1'

}

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "myproject"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

我希望这些信息足够,如果需要其他任何信息,请告诉我。

0 个答案:

没有答案