【问题标题】:ANDROID: Error W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not foundANDROID:错误 W/DynamiteModule:com.google.android.gms.googlecertificates 的本地模块描述符类未找到
【发布时间】:2017-03-26 11:23:30
【问题描述】:

我正在尝试使用 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

它提到了一些关于谷歌证书的东西,这就是为什么我认为它可能与密钥有关......但我不确定,我不知道我做错了什么。

感谢您的帮助。

////////

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

public class MapsActivity extends FragmentActivity implements 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));
    }
}

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

【问题讨论】:

  • 能否也包含一些代码?
  • 尝试在 Google Developer Console 上更新您项目中的 SHA1 密钥,并在您的 android 项目中更新 Google Maps API 密钥。为了更好地理解,请确保您正确遵循此documentation 中给出的步骤,尤其是"Where to get your app's SHA-1 fingerprint" 的部分
  • 嗨,Raquel,你修好了吗? (我这里有同样的问题)
  • 我面临同样的问题...如果您找到任何解决方案,请告诉我。 @Raquel

标签: java android google-maps


【解决方案1】:

加载证书可能是 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();
                }

【讨论】:

  • 提示:你有很多代码 - 非常懒惰地格式化/缩进。请使用那个预览窗口来确保你不会倾倒一些乱七八糟的代码,而是一些人们会觉得足够可读的东西。
【解决方案2】:

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

【讨论】:

  • 更新:为所选 API 版本下载更新的 Google Play 服务 -> 删除并重新安装该 API 的模拟器 -> 重新启动 Android Studio 即可。
猜你喜欢
  • 2018-03-27
  • 2018-06-13
  • 1970-01-01
  • 1970-01-01
  • 2022-08-09
  • 2017-04-18
  • 2016-11-30
  • 2022-10-23
  • 2017-09-11
相关资源
最近更新 更多