一切正常,直到我更新我的android工具rev 22.3,android sdk平台工具rev 19.0.1,android支持库rev 19.0.1,google play services rev 15。
现在每当我使用谷歌地图访问我的活动时,我的应用程序崩溃了。 logcat的:
02-24 21:18:55.336: E/AndroidRuntime(23474): FATAL EXCEPTION: main
02-24 21:18:55.336: E/AndroidRuntime(23474): java.lang.RuntimeException: Unable to start activity ComponentInfo{packagename}: java.lang.NullPointerException
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.app.ActivityThread.access$600(ActivityThread.java:162)
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.os.Handler.dispatchMessage(Handler.java:107)
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.os.Looper.loop(Looper.java:194)
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.app.ActivityThread.main(ActivityThread.java:5371)
02-24 21:18:55.336: E/AndroidRuntime(23474): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 21:18:55.336: E/AndroidRuntime(23474): at java.lang.reflect.Method.invoke(Method.java:525)
02-24 21:18:55.336: E/AndroidRuntime(23474): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
02-24 21:18:55.336: E/AndroidRuntime(23474): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
02-24 21:18:55.336: E/AndroidRuntime(23474): at dalvik.system.NativeStart.main(Native Method)
02-24 21:18:55.336: E/AndroidRuntime(23474): Caused by: java.lang.NullPointerException
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.app.Activity.performCreate(Activity.java:5122)
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
02-24 21:18:55.336: E/AndroidRuntime(23474): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
清单:
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<permission
android:name="packagename.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="packagename.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<activity android:name="packagename.balona.MapDetail" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="key" />
// I add these based on this post http://stackoverflow.com/questions/19724113/google-play-services-update
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<uses-library android:name="com.google.android.maps" />
XML:
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
OnCreate谷歌地图活动:
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
googleMap = fm.getMap();
googleMap.setMyLocationEnabled(true);
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
直到我在Android SDK Manager中更新了上面所说的内容之前,它才能正常工作。我该怎么办?请帮忙。我应该重新安装我的eclipse adt吗?
答案 0 :(得分:1)
尝试添加清理项目并刷新后甚至尝试重新启动虚拟设备..
答案 1 :(得分:0)
当我没有将playServices项目作为依赖项添加到构建属性中的项目时,我遇到了类似的问题。
请查看tutorial。
但也很好的想法是在播放服务的示例项目的addons文件夹中查看android sdk,并将其简单地添加为项目的依赖项。
将该项目作为依赖项添加到您的项目中 ** SDK \额外\谷歌\ google_play_services \ libproject \ Google处理播放services_lib **