简体   繁体   中英

E/AndroidRuntime(622): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable

public class MainActivity extends FragmentActivity {

private GoogleMap mMap;

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


private void setUpMapIfNeeded() {
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                .getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            setUpMap();
        }
    }

}


private void setUpMap() {
    mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));

}


@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    setUpMapIfNeeded();
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
} 

I got this exception:

08-01 12:16:59.522: D/dalvikvm(622): Not late-enabling CheckJNI (already on)
08-01 12:17:00.781: W/dalvikvm(622): VFY: unable to resolve static field 1228 (MapAttrs) in Lcom/google/android/gms/R$styleable;
08-01 12:17:00.781: D/dalvikvm(622): VFY: replacing opcode 0x62 at 0x000e
08-01 12:17:00.791: D/AndroidRuntime(622): Shutting down VM
08-01 12:17:00.791: W/dalvikvm(622): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
08-01 12:17:00.831: E/AndroidRuntime(622): FATAL EXCEPTION: main
08-01 12:17:00.831: E/AndroidRuntime(622): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
08-01 12:17:00.831: E/AndroidRuntime(622):  at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
08-01 12:17:00.831: E/AndroidRuntime(622):  at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:284)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-01 12:17:00.831: E/AndroidRuntime(622):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.app.Activity.setContentView(Activity.java:1835)
08-01 12:17:00.831: E/AndroidRuntime(622):  at com.test.map.MainActivity.onCreate(MainActivity.java:20)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.app.Activity.performCreate(Activity.java:4465)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.os.Looper.loop(Looper.java:137)
08-01 12:17:00.831: E/AndroidRuntime(622):  at android.app.ActivityThread.main(ActivityThread.java:4424)
08-01 12:17:00.831: E/AndroidRuntime(622):  at java.lang.reflect.Method.invokeNative(Native Method)
08-01 12:17:00.831: E/AndroidRuntime(622):  at java.lang.reflect.Method.invoke(Method.java:511)
08-01 12:17:00.831: E/AndroidRuntime(622):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-01 12:17:00.831: E/AndroidRuntime(622):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-01 12:17:00.831: E/AndroidRuntime(622):  at dalvik.system.NativeStart.main(Native Method)

Try this

In Eclipse go to:

Project -> Properties -> Java Build Properties

On the "Order and Export" tab I checked "Android Private Libraries" on my project. I also did this for the library project it references. This fixed my class not found errors following upgrading to SDK 22.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM