Could not find class 'com.google.android.gms.l

2019-01-24 16:38发布

问题:

I have an app where homepage is map.

Do not know why i am getting this error and along with this error Could not find class 'gpr', referenced from method gps.a

I have updated eclipse so i tried to change to API key with new SHA1 fingerprint. But that does not work.

My app is to show current location when you open the app. It just landed into whole map but in LOG cat i get these error. Here is my Logcat

`07-08 12:54:39.897: I/Google Maps Android API(25749): Google Play services client version: 5077000

 07-08 12:54:39.907: I/dalvikvm(25749): Could not find method guj.a, referenced from method gqi.a

 07-08 12:54:39.907: W/dalvikvm(25749): VFY: unable to resolve static method 24936: Lguj;.a (Landroid/content/Context;)Lgri;

 07-08 12:54:39.907: D/dalvikvm(25749): VFY: replacing opcode 0x71 at 0x0003

 07-08 12:54:39.917: E/dalvikvm(25749): Could not find class 'gpr', referenced from method gps.a

 07-08 12:54:39.917: W/dalvikvm(25749): VFY: unable to resolve new-instance 4090 (Lgpr;) in Lgps;

 07-08 12:54:39.917: D/dalvikvm(25749): VFY: replacing opcode 0x22 at 0x0000

 07-08 12:54:39.927: E/dalvikvm(25749): Could not find class 'gpr', referenced from method gps.a

 07-08 12:54:39.927: W/dalvikvm(25749): VFY: unable to resolve new-instance 4090 (Lgpr;) in Lgps;

 07-08 12:54:39.927: D/dalvikvm(25749): VFY: replacing opcode 0x22 at 0x0000

 07-08 12:54:39.927: E/dalvikvm(25749): Could not find class 'gpr', referenced from method gps.a

 07-08 12:54:39.927: W/dalvikvm(25749): VFY: unable to resolve new-instance 4090 (Lgpr;) in Lgps;

 07-08 12:54:39.927: D/dalvikvm(25749): VFY: replacing opcode 0x22 at 0x0000

 07-08 12:54:39.937: D/dalvikvm(25749): DexOpt: unable to opt direct call 0x5ea3 at 0x0a in Lgps;.a

 07-08 12:54:39.937: D/dalvikvm(25749): DexOpt: unable to opt direct call 0x5ea3 at 0x0c in Lgps;.a

 07-08 12:54:39.937: D/dalvikvm(25749): DexOpt: unable to opt direct call 0x5ea3 at 0x0a in Lgps;.a

 07-08 12:54:39.957: I/Google Maps Android API(25749): Google Play services package version: 5084034

 07-08 12:54:39.977: W/dalvikvm(25749): VFY: unable to resolve static field 20873 (t) in Lyp;

 07-08 12:54:39.977: D/dalvikvm(25749): VFY: replacing opcode 0x62 at 0x000e
 07-08 12:54:39.977: W/dalvikvm(25749): VFY: unable to resolve static field 20873 (t) in Lyp;

 07-08 12:54:39.977: D/dalvikvm(25749): VFY: replacing opcode 0x62 at 0x000d

 07-08 12:54:40.888: I/dalvikvm(25749): Failed resolving Lcom/google/android/gms/location/internal/ParcelableGeofence; interface 4023 'Lgln;'

 07-08 12:54:40.888: W/dalvikvm(25749): Link of class 'Lcom/google/android/gms/location/internal/ParcelableGeofence;' failed

 07-08 12:54:40.898: E/dalvikvm(25749): Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence', referenced from method glt.a

 07-08 12:54:40.898: W/dalvikvm(25749): VFY: unable to resolve check-cast 2086 (Lcom/google/android/gms/location/internal/ParcelableGeofence;) in Lglt;

 07-08 12:54:40.898: D/dalvikvm(25749): VFY: replacing opcode 0x1f at 0x0019

 07-08 12:54:41.589: W/ActivityThread(25749): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());`

I tried to Google it around and it seems there is no proper solution yet so it would be helpful if anybody could help me with this.

回答1:

I show you how I solved the same problem you have.

First of all, I cleaned all sdk and I downloaded again Google Play Services lib. Then I removed .android folder of my computer and I regenerated my debug.keystore.

After that, I just get my new SHA1 to obtain my Google Maps V2 Api Key.

After update my apikey, let's see how I change my code.

Now I use fragment with MapFragment insted of MapView in your xml layout.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapsActivity" >

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

</RelativeLayout> 

And use FragmentManager to locate it:

    public class MapsActivity extends Activity
{
    private GoogleMap map;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

        // Gets the MapView from the XML layout and creates it
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
        map.getUiSettings().setMyLocationButtonEnabled(false);
        //map.setMyLocationEnabled(true);
        map.setOnMapClickListener(this);
        map.setOnMapLongClickListener(this);
        try 
        {
            MapsInitializer.initialize(MapsActivity.this);
        } 
        catch (Exception e) 
        {
            e.printStackTrace();
        }
    }

I hope that's helpfull and sorry if my english is so bad, regards



回答2:

I had the same issue after upgrading to API Level 23 in July (with client google-play-service_lib 5.0.77).

The issue was resolved after Google Play Service was updated to latest (6.1.09) on the test device.

So, it seems to have been (a device-specific issue) due to incompatibility between the Google Play Service version on the device/emulator and the client library API (google-play-service_lib) in the project.

According to Google's documentation, when the client is newer than the service, the client library API is supposed to resolve out-of-date service apk issues; (and it does in this case since the issue does not really affect released apk's) https://developer.android.com/google/play-services/index.html.

My earlier attempts to resolve this issue by using new API key, and fresh installs of Eclipse/ADT/SDK/google-play-service_lib, as suggested in this and other similar questions did not work.



回答3:

Could you post your manifest? Sans API key, of course.

Your log looks almost identical to mine for a problem I've had recently, which was fixed by adding the following to the manifest:

 <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

I'm working on an application that was accessing maps just fine, then stopped out of the blue. I couldn't see anything actually pointing to a missing permission; I only picked up on it when I compared the manifest with another application that used maps api v2.

I'm still confused as to why it previously worked without it (Google says you need the permission for maps to work). Perhaps I'd once put it there and accidentally deleted the line, but either way putting it in is what fixed it.

Source: https://developers.google.com/maps/documentation/business/mobile/android/config