我正在开发 android 中的 Googl Maps API v2。
MapExample.java 代码
public class MapExample extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
main.xml 代码
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
清单文件代码
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-feature android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.example.android.mapexample.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses_permission android:name="com.example.android.mapexample.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="My API_KEY"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我在模拟器中运行此代码它在模拟器中显示一条消息并在 LogCat 中显示警告
消息:您的某些应用程序所依赖的 Google Play 服务不受您的设备支持。请联系制造商以获取有关确定按钮的帮助。警告:Google Play 签名无效。
每当单击该按钮时,我都会收到错误
03-02 13:17:30.746: D/AndroidRuntime(905): Shutting down VM
03-02 13:17:30.746: W/dalvikvm(905): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
03-02 13:17:30.776: E/AndroidRuntime(905): FATAL EXCEPTION: main
03-02 13:17:30.776: E/AndroidRuntime(905): java.lang.NullPointerException
03-02 13:17:30.776: E/AndroidRuntime(905): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1409)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.app.Activity.startActivityForResult(Activity.java:3351)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.app.Activity.startActivityForResult(Activity.java:3312)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.app.Activity.startActivity(Activity.java:3522)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.app.Activity.startActivity(Activity.java:3490)
03-02 13:17:30.776: E/AndroidRuntime(905): at com.google.android.gms.internal.e$2.onClick(Unknown Source)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.view.View.performClick(View.java:4084)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.view.View$PerformClick.run(View.java:16966)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.os.Handler.handleCallback(Handler.java:615)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.os.Handler.dispatchMessage(Handler.java:92)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.os.Looper.loop(Looper.java:137)
03-02 13:17:30.776: E/AndroidRuntime(905): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-02 13:17:30.776: E/AndroidRuntime(905): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 13:17:30.776: E/AndroidRuntime(905): at java.lang.reflect.Method.invoke(Method.java:511)
03-02 13:17:30.776: E/AndroidRuntime(905): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-02 13:17:30.776: E/AndroidRuntime(905): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-02 13:17:30.776: E/AndroidRuntime(905): at dalvik.system.NativeStart.main(Native Method)
我怎样才能解决这个问题?