我正在尝试在模拟器上测试我的应用程序,但它无法正常工作。但是,它在我的手机上工作正常。我有一个版本4.0.3的三星Galaxy S2。如何创建一个可以使用它的模拟器?
这些是错误,它位于pastebin http://pastebin.com/PR65kGxg:
中03-05 15:03:16.777: W/Trace(856): Unexpected value from nativeGetEnabledTags: 0
03-05 15:03:16.967: W/Trace(856): Unexpected value from nativeGetEnabledTags: 0
03-05 15:03:16.967: W/Trace(856): Unexpected value from nativeGetEnabledTags: 0
03-05 15:03:17.387: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.427: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.467: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.497: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.527: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.887: W/GooglePlayServicesUtil(856): Google Play services out of date. Requires 2012100 but found 1015
03-05 15:03:17.887: D/AndroidRuntime(856): Shutting down VM
03-05 15:03:17.897: W/dalvikvm(856): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
03-05 15:03:17.917: E/AndroidRuntime(856): FATAL EXCEPTION: main
03-05 15:03:17.917: E/AndroidRuntime(856): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.neatspots/com.example.neatspots.MainActivity}: java.lang.NullPointerException
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.os.Looper.loop(Looper.java:137)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-05 15:03:17.917: E/AndroidRuntime(856): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 15:03:17.917: E/AndroidRuntime(856): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 15:03:17.917: E/AndroidRuntime(856): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-05 15:03:17.917: E/AndroidRuntime(856): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-05 15:03:17.917: E/AndroidRuntime(856): at dalvik.system.NativeStart.main(Native Method)
03-05 15:03:17.917: E/AndroidRuntime(856): Caused by: java.lang.NullPointerException
03-05 15:03:17.917: E/AndroidRuntime(856): at com.example.neatspots.MainActivity.setMapDefaults(MainActivity.java:89)
03-05 15:03:17.917: E/AndroidRuntime(856): at com.example.neatspots.MainActivity.onCreate(MainActivity.java:73)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.Activity.performCreate(Activity.java:5104)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-05 15:03:17.917: E/AndroidRuntime(856): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-05 15:03:17.917: E/AndroidRuntime(856): ... 11 more
03-05 15:03:18.187: D/dalvikvm(856): GC_CONCURRENT freed 244K, 13% free 2530K/2892K, paused 8ms+71ms, total 260ms
03-05 15:03:37.127: I/Process(856): Sending signal. PID: 856 SIG: 9
这是第89行:
public void setMapDefaults()
{
map.setMapType(GoogleMap.MAP_TYPE_NORMAL); //line 89
map.setMyLocationEnabled(true);
}
答案 0 :(得分:1)
创建一个新的虚拟设备,并在目标中选择Google API等级17,它将有效。
答案 1 :(得分:0)
您的应用使用地图API,因此请检查模拟器是否具有Google API 4.0目标,而不是简单的Android 4.0
答案 2 :(得分:0)
确定。我阅读了SO复制指南并认为这个问题与this question不同,以便得出一个答案,说明“这可能是与这个问题相同的问题”类型答案/评论的事情。任何版主都可以自由地整理一下。
基本上 - 尽管NPE,Jonathan的代码仍然很好。这可能是模拟器 - Google V2 Play服务兼容性问题。