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

时间:2013-08-01 12:50:42

标签: android google-maps

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;
}
} 

我遇到了这个例外:

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)

1 个答案:

答案 0 :(得分:0)

试试这个

在Eclipse中转到:

项目 - >属性 - > Java构建属性

在“订购和导出”标签上,我检查了项目中的“Android私有库”。我也为它引用的库项目做了这个。这修复了我升级到SDK 22后未找到错误的类。