web-dev-qa-db-ja.com

RuntimeException:APIキーが見つかりません。 geo.API_KEYがAndroidManifest.xmlにあることを確認します

携帯電話で簡単な地図表示を編集しようとしていますが、アプリが閉じ続けます。アヒルが一列に並んでいるようですが、困っています。 Android StudioでAPIを使用するのは初めてです

ここにマニフェストがあります:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:Android="http://schemas.Android.com/apk/res/Android"
package="com.morticia.Android.firstmap">

<uses-feature
    Android:glEsVersion="0x00020000"
    Android:required="true" />
<application
    Android:allowBackup="true"
    Android:icon="@mipmap/ic_launcher"
    Android:label="@string/app_name"
    Android:supportsRtl="true"
    Android:theme="@style/AppTheme">
    <meta-data
        Android:name="com.google.Android.gms.version"
        Android:value="@integer/google_play_services_version" />
    <meta-data
        Android:name="com.morticia.Android.maptest_app"
        Android:value="AIzaSyBf3tEmdR18S-2v0E1i1x0oqcXJ9imntT4" />

    <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>

<uses-permission Android:name="Android.permission.INTERNET"></uses-permission>
<uses-permission Android:name="Android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission Android:name="Android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
</manifest>

そして、これが私のMainActivity XMLです。

<RelativeLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
xmlns:tools="http://schemas.Android.com/tools"
xmlns:map="http://schemas.Android.com/apk/res-auto"
Android:layout_height="match_parent"
Android:layout_width="match_parent"
Android:paddingBottom="@dimen/activity_vertical_margin"
Android:paddingLeft="@dimen/activity_horizontal_margin"
Android:paddingRight="@dimen/activity_horizontal_margin"
Android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<fragment xmlns:Android="http://schemas.Android.com/apk/res/Android"
    Android:id="@+id/map"
    Android:layout_height="match_parent"
    Android:layout_width="match_parent"
    Android:name="com.google.Android.gms.maps.MapFragment"
    map:cameraBearing="112.5"
    map:cameraTargetLat="40.7484"
    map:cameraTargetLng="-73.9857"
    map:cameraTilt="65"
    map:cameraZoom="17" />

</RelativeLayout>

そして最後にMainActivity Javaコード:

package com.morticia.Android.firstmap;

import Android.support.v7.app.AppCompatActivity;
import Android.os.Bundle;

import com.google.Android.gms.maps.MapFragment;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
}

リクエストされたログは次のとおりです。

02-02 20:29:13.420 26932-26932/com.morticia.Android.firstmap E/AndroidRuntime: FATAL EXCEPTION: main
                                                                           Process: com.morticia.Android.firstmap, PID: 26932
                                                                           Java.lang.RuntimeException: Unable to start activity ComponentInfo{com.morticia.Android.firstmap/com.morticia.Android.firstmap.MainActivity}: Android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class fragment
                                                                               at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:3253)
                                                                               at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:3349)
                                                                               at Android.app.ActivityThread.access$1100(ActivityThread.Java:221)
                                                                               at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1794)
                                                                               at Android.os.Handler.dispatchMessage(Handler.Java:102)
                                                                               at Android.os.Looper.loop(Looper.Java:158)
                                                                               at Android.app.ActivityThread.main(ActivityThread.Java:7224)
                                                                               at Java.lang.reflect.Method.invoke(Native Method)
                                                                               at com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.Java:1230)
                                                                               at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:1120)
                                                                            Caused by: Android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class fragment
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:551)
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:429)
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:380)
                                                                               at Android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.Java:288)
                                                                               at Android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.Java:143)
                                                                               at com.morticia.Android.firstmap.MainActivity.onCreate(MainActivity.Java:13)
                                                                               at Android.app.Activity.performCreate(Activity.Java:6876)
                                                                               at Android.app.Instrumentation.callActivityOnCreate(Instrumentation.Java:1135)
                                                                               at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:3206)
                                                                               at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:3349) 
                                                                               at Android.app.ActivityThread.access$1100(ActivityThread.Java:221) 
                                                                               at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1794) 
                                                                               at Android.os.Handler.dispatchMessage(Handler.Java:102) 
                                                                               at Android.os.Looper.loop(Looper.Java:158) 
                                                                               at Android.app.ActivityThread.main(ActivityThread.Java:7224) 
                                                                               at Java.lang.reflect.Method.invoke(Native Method) 
                                                                               at com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.Java:1230) 
                                                                               at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:1120) 
                                                                            Caused by: Android.view.InflateException: Binary XML file line #12: Error inflating class fragment
                                                                               at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:794)
                                                                               at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:716)
                                                                               at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:847)
                                                                               at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:810)
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:527)
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:429) 
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:380) 
                                                                               at Android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.Java:288) 
                                                                               at Android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.Java:143) 
                                                                               at com.morticia.Android.firstmap.MainActivity.onCreate(MainActivity.Java:13) 
                                                                               at Android.app.Activity.performCreate(Activity.Java:6876) 
                                                                               at Android.app.Instrumentation.callActivityOnCreate(Instrumentation.Java:1135) 
                                                                               at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:3206) 
                                                                               at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:3349) 
                                                                               at Android.app.ActivityThread.access$1100(ActivityThread.Java:221) 
                                                                               at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1794) 
                                                                               at Android.os.Handler.dispatchMessage(Handler.Java:102) 
                                                                               at Android.os.Looper.loop(Looper.Java:158) 
                                                                               at Android.app.ActivityThread.main(ActivityThread.Java:7224) 
                                                                               at Java.lang.reflect.Method.invoke(Native Method) 
                                                                               at com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.Java:1230) 
                                                                               at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:1120) 
                                                                            Caused by: Java.lang.RuntimeException: API key not found.  Check that <meta-data Android:name="com.google.Android.geo.API_KEY" Android:value="your API key"/> is in the <application> element of AndroidManifest.xml
                                                                               at maps.y.k.b(Unknown Source)
                                                                               at maps.v.c.a(Unknown Source)
                                                                               at com.google.Android.gms.maps.internal.CreatorImpl.b(Unknown Source)
                                                                               at com.google.Android.gms.maps.internal.CreatorImpl.newMapFragmentDelegate(Unknown Source)
                                                                               at xg.onTransact(:com.google.Android.gms.DynamiteModulesB:62)
                                                                               at Android.os.Binder.transact(Binder.Java:387)
                                                                               at trn.newMapFragmentDelegate(:com.google.Android.gms:179)
                                                                               at com.google.Android.gms.maps.internal.CreatorImpl.newMapFragmentDelegate(:com.google.Android.gms:99)
                                                                               at trm.onTransact(:com.google.Android.gms:62)
                                                                               at Android.os.Binder.transact(Binder.Java:387)
                                                                               at com.google.Android.gms.maps.internal.zzc$zza$zza.zzt(Unknown Source)
                                                                               at com.google.Android.gms.maps.MapFragment$zzb.zzwP(Unknown Source)
                                                                               at com.google.Android.gms.maps.MapFragment$zzb.zza(Unknown Source)
                                                                               at com.google.Android.gms.dynamic.zza.zza(Unknown Source)
                                                                               at com.google.Android.gms.dynamic.zza.onInflate(Unknown Source)
                                                                               at com.google.Android.gms.maps.MapFragment.onInflate(Unknown Source)
                                                                               at Android.app.Fragment.onInflate(Fragment.Java:1373)
                                                                               at Android.app.FragmentManagerImpl.onCreateView(FragmentManager.Java:2217)
                                                                               at Android.app.FragmentController.onCreateView(FragmentController.Java:98)
                                                                               at Android.app.Activity.onCreateView(Activity.Java:6070)
                                                                               at Android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.Java:36)
                                                                               at Android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.Java:79)
                                                                               at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:766)
                                                                               at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:716) 
                                                                               at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:847) 
                                                                               at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:810) 
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:527) 
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:429) 
                                                                               at Android.view.LayoutInflater.inflate(LayoutInflater.Java:380) 
                                                                               at Android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.Java:288) 
                                                                               at Android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.Java:143) 
                                                                               at com.morticia.Android.firstmap.MainActivity.onCreate(MainActivity.Java:13) 
                                                                               at Android.app.Activity.performCreate(Activity.Java:6876) 
                                                                               at Android.app.Instrumentation.callActivityOnCreate(Instrumentation.Java:1135) 
                                                                               at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:3206) 
                                                                               at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:3349) 
                                                                               at Android.app.ActivityThread.access$1100(ActivityThread.Java:221) 
                                                                               at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1794) 
                                                                               at Android.os.Handler.dispatchMessage(Handler.Java:102) 
                                                                               at Android.os.Looper.loop(Looper.Java:158) 
                                                                               at Android.app.ActivityThread.main(ActivityThread.Java:7224) 
                                                                               at Java.lang.reflect.Method.invoke(Native Method) 
                                                                               at com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.Java:1230) 
                                                                               at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:1120) 

どんな専門的な洞察もいただければ幸いです

ありがとうございました!

10
TJBlack31

このコードをAndroidManifest.xmlファイルで置き換えます

  <meta-data
    Android:name="com.morticia.Android.maptest_app"
    Android:value="YOUR_API_KEY" />

GoogleマップAndroid API ENABLE

  <meta-data Android:name="com.google.Android.maps.v2.API_KEY"
    Android:value="YOUR_MAP_API" />

または

Google Maps Geolocation API ENABLE

<meta-data Android:name="com.google.Android.geo.API_KEY" 
Android:value="YOUR_GEO_API"/>
13
Ankush Bist

あなたは置くべきです

<application
   <meta-data Android:name="com.google.Android.geo.API_KEY" Android:value="<put your api KEY here"/>  
...

およびnotは、たとえば以下のような他の位置にあります。

<application
   <activity
      <meta-data Android:name="com.google.Android.geo.API_KEY" Android:value="<put your api KEY here"/>  
4

Android:name = "com.google.Android.gms.maps.MapFragment"をclass = "com.google.Android.gms.maps.SupportMapFragment"に置き換えて試してください。

0
Pratik Popat

私はこれに遭遇しましたが、EXPOを使用しているため、解決策は少し異なります。簡単に言えば、マップの以下の「config」をpackage.jsonに追加する必要があります。

"Android": {
      "package": "com.YOUR_PROJECT_NAME",
      "versionCode": 1.0,
      "permissions": [
        "ACCESS_COARSE_LOCATION",
        "CAMERA",
      ],
      "config": {
        "googleMaps": {
          "apiKey": "YOUR API KEY GOES HERE"
        }
      }
    },

詳細はこちらをご覧ください: https://docs.expo.io/versions/latest/sdk/map-view/

0
David Pears