【问题标题】:Error: Execution failed for task ':app:generateDebugBuildConfig'错误:任务“:app:generateDebugBuildConfig”执行失败
【发布时间】:2021-03-03 03:48:31
【问题描述】:

我正在为 Google 地图构建一个使用 Cordova 插件的应用。我不断收到此错误,不知道如何修复它或它甚至意味着什么。任何帮助,将不胜感激。这是错误:

* What went wrong:
Execution failed for task ':app:generateDebugBuildConfig'.
> Failed to calculate the value of task ':app:generateDebugBuildConfig' property 'buildConfigPackageName'.
   > org.xml.sax.SAXParseException; systemId: file:/C:/Users/Amanda/Desktop/project2/platforms/android/app/src/main/AndroidManifest.xml; lineNumber: 5; columnNumber: 184; The prefix "tools" for attribute "tools:overrideLibrary" associated with an element type "application" is not bound.

还有我的 AndroidManifest.xml:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.example.project2" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" tools:overrideLibrary="za.co.twyst">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data android:name="com.google.android.geo.API_KEY" android:value="${GOOGLE_MAPS_ANDROID_API_KEY}" />
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
    <uses-feature android:name="android.hardware.location" />
    <uses-feature android:name="android.hardware.location.gps" />
</manifest>

【问题讨论】:

    标签: android-studio google-maps cordova cordova-plugins


    【解决方案1】:

    错误

    org.xml.sax.SAXParseException; 
    systemId: file:/C:/Users/Amanda/Desktop/project2/platforms/android/app/src/main/AndroidManifest.xml; 
    lineNumber: 5; columnNumber: 184;
    The prefix "tools" for attribute "tools:overrideLibrary" associated with an element type "application" is not bound.
    

    如您所见,错误位于第 5 行和第 184 列。正如建议的那样,我认为您缺少名称空间

    xmlns:tools="http://schemas.android.com/tools"
    

    将此添加到您的清单中,以便您的清单看起来像这样

    <?xml version='1.0' encoding='utf-8'?>
    <manifest android:hardwareAccelerated="true"
        android:versionCode="10000"
        android:versionName="1.0.0"
        package="com.example.project2"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools">
        <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
        <uses-permission android:name="android.permission.INTERNET" />
        <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" tools:overrideLibrary="za.co.twyst">
            <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
                <intent-filter android:label="@string/launcher_name">
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <meta-data android:name="com.google.android.geo.API_KEY" android:value="${GOOGLE_MAPS_ANDROID_API_KEY}" />
            <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
            <uses-library android:name="org.apache.http.legacy" android:required="false" />
        </application>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-feature android:glEsVersion="0x00020000" android:required="true" />
        <uses-feature android:name="android.hardware.location" />
        <uses-feature android:name="android.hardware.location.gps" />
    </manifest>
    

    【讨论】:

    • 我尝试了你的建议并得到另一个错误Manifest merger failed:uses-sdk:minSdkVersion 14 cannot be smaller than version 19 declared in library [:tbxml-android:] C:\...\AndroidManifest.xml as the library might be using APIs not available in 14 Suggestion: use a compatible library with a minSdk of at most 14, or increase this project's minSdk version to at least 19, or use tools:overrideLibrary="za.co.twyst" to force usage (may lead to runtime failures)我很困惑。
    • 你使用的最小 SDK 是什么,检查 build.gradle
    • 我正在使用 minSDK 19
    • 你能粘贴你的build.gradle吗
    猜你喜欢
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    • 2018-02-17
    • 2018-06-06
    相关资源
    最近更新 更多