ANDROID:错误W / DynamiteModule:找不到com.google.android.gms.googlecertificates的本地模块描述符类

时间:2016-11-12 09:18:22

标签: java android google-maps

我正在尝试使用Android Studio进行MapActivity。它必须显示用户的位置。

嗯,我知道我需要一个密钥才能使用API​​,相信我,我至少改变了四次密钥...我还拥有AndroidManifest.xml中的权限。

问题是我可以在没有用户位置的情况下显示地图,但如果我尝试显示他/她的位置,那么应用程序编译得很好但是当我尝试执行它时,它会停止并且我会收到此错误:

11-12 09:13:28.416 21576-21653/raquel.mapapplication W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
11-12 09:13:28.424 21576-21653/raquel.mapapplication I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:2
11-12 09:13:28.424 21576-21653/raquel.mapapplication I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 2
11-12 09:13:28.432 21576-21653/raquel.mapapplication W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/0000000b/n/armeabi
11-12 09:13:28.436 21576-21653/raquel.mapapplication D/GoogleCertificates: com.google.android.gms.googlecertificates module is loaded
11-12 09:13:28.504 21576-21653/raquel.mapapplication D/GoogleCertificatesImpl: Fetched 190 Google release certificates
11-12 09:13:28.505 21576-21653/raquel.mapapplication D/GoogleCertificatesImpl: Fetched 363 Google certificates
11-12 09:13:31.235 21576-21576/raquel.mapapplication I/Process: Sending signal. PID: 21576 SIG: 9

它提到了Google Certificates的内容,这就是为什么我认为它可能与密钥有关......但我不确定,我不知道我做错了什么。

感谢您的帮助。

////////

好的,我会尝试发布一些代码......我一直在更改代码,但这是我尝试过的最后一次(我也试过了setMyLocationEnable(true),因为不推荐使用getMyLocation(),但我获得相同的错误):

public class MapsActivity extends FragmentActivity实现了OnMapReadyCallback {

private GoogleMap mMap;

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

    Location location=mMap.getMyLocation();

    double lat=location.getLatitude();
    double lon=location.getLongitude();

    // Add a marker in Sydney and move the camera
    LatLng sydney = new LatLng(lat, lon);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}

}

感谢回答我的人和编辑我评论的人......我仍然不太清楚如何格式化文本...

2 个答案:

答案 0 :(得分:1)

打开sdk manager,下载/更新google play services。 并创建一个新的模拟器。

答案 1 :(得分:0)

加载证书可能是API中的错误,我认为任何谷歌开发人员都曾描述过,游戏服务正试图登录以验证播放应用或第三方应用,这可能是错误。我不太了解它。

但是如果您仍然无法在用户位置放置标记,您可以尝试使用以下代码进行测试并在应用程序中工作

@Override
public void onMapReady(GoogleMap googleMap)

{
    myGoogleMap = googleMap;
    placeMarkerOnPosition();
}

public void placeMarkerOnPosition() {
//// check permissions to access resources ///////// 
if (ActivityCompat.checkSelfPermission(this, 
android.Manifest.permission.ACCESS_FINE_LOCATION) != 
PackageManager.PERMISSION_GRANTED && 
ActivityCompat.checkSelfPermission(this, 
android.Manifest.permission.ACCESS_COARSE_LOCATION) != 
PackageManager.PERMISSION_GRANTED) {

    return;
}
    LocationManager locationManager = (LocationManager) 
    getSystemService(Context.LOCATION_SERVICE);

现在你可以用两种方式找到它

////////////////  find location if GPS provider is available (GPS should 
enable to envoke this callback)

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, 
new LocationListener() 
{
 @Override
 public void onLocationChanged(Location location) {

try {
    Geocoder geocoder = new Geocoder(getApplicationContext());                              
    myLatitude = location.getLatitude();
    myLongitude = location.getLongitude();
    LatLng myPosition = new LatLng(myLatitude,myLongitude);
    List<Address> places=geocoder.getFromLocation(myLatitude, 
    myLongitude,1);
    myLocation = places.get(0).getSubLocality() 
                 +""+places.get(0).getLocality();

    myGoogleMap.clear();
    myGoogleMap.addMarker(new 
    MarkerOptions().position(myPosition).title(myLocation));

    myGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(myPosition, 
                                                                 13.5f));


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

    @Override
    public void onStatusChanged(String s, int i, Bundle bundle) {

    }

    @Override
    public void onProviderEnabled(String s) {

    }

    @Override
    public void onProviderDisabled(String s) {

    }
    });

////////////////   checking with network providers   /////////


if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {


locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 
                                       0, new LocationListener() {
@Override
public void onLocationChanged(Location location) {
myLatitude = location.getLatitude();
myLongitude = location.getLongitude();
LatLng myPosition = new LatLng(myLatitude, myLongitude);
myGoogleMap.clear();
myGoogleMap.addMarker(new MarkerOptions().position(myPosition).title("My 
                                                             Position"));

myGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(myPosition, 
                                                              13.5f));

}

                @Override
                public void onStatusChanged(String s, int i, Bundle bundle) 
                {

                }

                @Override
                public void onProviderEnabled(String s) {

                }

                @Override
                public void onProviderDisabled(String s) {

                }
            });

        }

   ////////  Or you can find it with user  recent location //////////

   Criteria criteria = new Criteria();
   String bestProvider = locationManager.getBestProvider(criteria,true);
   Locationlocation=locationManager.getLastKnownLocation(bestProvider);

   //////////   load your location from last recent locations ////////
            if (location != null) {
                Geocoder geocoder = new Geocoder(getApplicationContext());

                try {
                    myLatitude = location.getLatitude();
                    myLongitude = location.getLongitude();
                    LatLng myPosition = new LatLng(myLatitude, myLongitude);
                    List<Address> places = 
                    geocoder.getFromLocation(myLatitude, myLongitude, 1);
                    myLocation = places.get(0).getSubLocality() + " " + places.get(0).getLocality();

                    myGoogleMap.clear();
                    myGoogleMap.addMarker(new MarkerOptions().position(myPosition).title(myLocation));
                    myGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(myPosition, 13.5f));


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