我正在使用 Jetpack Compose 并尝试将 Google 地图集成到我的应用程序中。我已按照文档设置API 密钥。但是,我在构建项目时遇到错误。在我的local.properties文件中,我有以下代码:
MAPS_API_KEY=my_api_key
Run Code Online (Sandbox Code Playgroud)
在我的AndroidManifest.xml我有以下代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.guidemetravelersapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.GuideMeTravelersApp">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${MAPS_API_KEY}" />
<activity
android:name=".homescreen.HomeScreen"
android:exported="true"
android:label="@string/title_activity_home_screen"
android:theme="@style/Theme.GuideMeTravelersApp.NoActionBar" />
<activity
android:name=".registerview.RegisterView"
android:exported="true"
android:label="@string/title_activity_register_view"
android:theme="@style/Theme.GuideMeTravelersApp.NoActionBar" />
<activity
android:name=".ExperienceDetailsView.ExperienceDetailsActivity"
android:exported="true"
android:label="@string/title_activity_experience_details"
android:theme="@style/Theme.GuideMeTravelersApp.NoActionBar" />
<activity
android:name=".LoginView.LoginActivity"
android:exported="true"
android:label="@string/title_activity_login"
android:theme="@style/Theme.GuideMeTravelersApp.NoActionBar" />
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.GuideMeTravelersApp.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
但是,这似乎还不够,因为在构建项目以查看预览时出现以下错误:
java.lang.IllegalStateException: A required meta-data tag in your app's …Run Code Online (Sandbox Code Playgroud)