2013-07-04 59 views
1

我想通過一個意圖這樣的改變活動打開一個嵌入式谷歌地圖一個fragmentactivity活動:簡單意圖改變不工作

Intent driver = new Intent(getApplicationContext(), DriverActivity.class); 
startActivity(driver); 

但應用程序崩潰,我最近從移動在我的Windows上的Eclipse到Ubuntu上的Eclipse。我看不出爲什麼該應用程序不會改變活動。調試器打開layoutInflater.class,窗口內的消息是:源未找到

有什麼問題,我該如何解決?

07-04 19:47:09.828: E/AndroidRuntime(30884): FATAL EXCEPTION: main 
07-04 19:47:09.828: E/AndroidRuntime(30884): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable 
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Activity.setContentView(Activity.java:1867) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.codele.blackcab.DriverActivity.onCreate(DriverActivity.java:51) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Activity.performCreate(Activity.java:5008) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.access$600(ActivityThread.java:138) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.os.Handler.dispatchMessage(Handler.java:99) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.os.Looper.loop(Looper.java:213) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.main(ActivityThread.java:4787) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at java.lang.reflect.Method.invokeNative(Native Method) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at java.lang.reflect.Method.invoke(Method.java:511) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 
07-04 19:47:09.828: E/AndroidRuntime(30884): at dalvik.system.NativeStart.main(Native Method) 
+0

你玩上與谷歌API的仿真器? –

+0

順便說一句,不要使用getApplicationContext()這種事情...而是使用當前的上下文,就像一個活動。 –

+0

@PozzoApps我正在使用物理設備來調試和部署 – timbillstrom

回答

1

使用此:

Intent driver = new Intent(this, DriverActivity.class); 
startActivity(driver); 
+0

不工作,我越來越'07-04 20:20:26.138:E/AndroidRuntime(3953):java.lang.NoClassDefFoundError:com.google.android.gms.R $ styleable'但是我的類在清單中註冊了 – timbillstrom

+0

請確保你有那個類出現在您的活動文件中。清理一次您的項目並嘗試重新運行它。 – Ponting