我正在使用Google Map Api创建一些应用。我加载了google_play_service,获得了API_KEY,将其插入Manifest.xml,但它确实无效。我做错了什么? 这是日志
9839-9839/com.example.miura.citytourbeta E/dalvikvm? Could not find class 'gpr', referenced from method gps.a
9839-9839/com.example.miura.citytourbeta E/dalvikvm? Could not find class 'gpr', referenced from method gps.a
9839-9839/com.example.miura.citytourbeta E/dalvikvm? Could not find class 'gpr', referenced from method gps.a
9839-9839/com.example.miura.citytourbeta E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{}
: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
at com.android.internal.os.ZygoteInit.main
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException:
Binary XML file line #6: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag
at android.view.LayoutInflater.rInflate
at android.view.LayoutInflater.inflate
at android.view.LayoutInflater.inflate
at android.view.LayoutInflater.inflate
Caused by: java.lang.RuntimeException: API key not found.
Check that <meta- data android:name="com.google.android.maps.v2.API_KEY"
android:value="your API key"/> is in the <application> element of AndroidManifest.xml
答案 0 :(得分:1)
在清单文件中的应用程序下添加以下元数据:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
答案 1 :(得分:0)
您是否在项目中添加了google_play_service.jar库?有时您需要导入google_play_service项目并将其标记为&#34;是库&#34;。你还得到同样的错误吗?