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

2022-09-04 04:33:15

我正在尝试使用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证书的事情,这就是为什么我认为也许它与密钥有关......但我不确定,我也不知道我做错了什么。

感谢您的帮助。

////////

好的,我会尝试发布一些代码...我一直在更改代码,但这是我最后一次尝试(我也尝试了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));
    }
}

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


答案 1

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


答案 2

加载证书可能是API中的错误,我认为任何Google开发人员也都已经描述过Play服务正在尝试登录以验证Play应用程序或第三方应用程序,因此这可能是错误。我对此一无所知。

但是,如果您仍然在用户位置上放置标记时遇到问题,则可以尝试下面的代码,我已经测试过它并且正在应用程序中工作

@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();
                }

推荐