我该如何解决此错误?资源链接失败

我正在尝试在手机上运行新应用,但遇到此错误:

  

Android资源链接失败C:\ Users \ HP PAVILION G6-   1310 \ miok \ app \ build \ intermediates \ merged_manifests \ debug \ AndroidManifest.xml:20:   错误:在中发现意外元素   

我在stackoverflow中找到了答案,但是没有一个对我有用。 这是我的所有文件:

应用程序:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'

    defaultConfig {
        applicationid "com.example.android.miwok"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs',include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

}

main \ AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.miwok">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsrtl="true"
        android:theme="@style/Apptheme">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        <activity
            android:name=".Numbersactivity"
            android:label="@string/category_numbers"
            android:parentactivityName=".Mainactivity">

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_actIVITY"
                android:value=".Mainactivity" />
        </activity>
        <activity
            android:name=".Familyactivity"
            android:label="@string/category_family"
            android:parentactivityName=".Mainactivity">

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_actIVITY"
                android:value=".Mainactivity" />
        </activity>
        <activity
            android:name=".Colorsactivity"
            android:label="@string/category_colors"
            android:parentactivityName=".Mainactivity">

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_actIVITY"
                android:value=".Mainactivity" />
        </activity>
        <activity
            android:name=".Phrasesactivity"
            android:label="@string/category_phrases"
            android:parentactivityName=".Mainactivity">

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_actIVITY"
                android:value=".Mainactivity" />
        </activity>

    </application>

</manifest>

debug \ AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.miwok"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="29" />

    <application
        android:allowBackup="true"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:debuggable="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsrtl="true"
        android:testOnly="true"
        android:theme="@style/Apptheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <activity
            android:name="com.example.android.miwok.Numbersactivity"
            android:label="@string/category_numbers"
            android:parentactivityName="com.example.android.miwok.Mainactivity" >

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_actIVITY"
                android:value=".Mainactivity" />
        </activity>
        <activity
            android:name="com.example.android.miwok.Familyactivity"
            android:label="@string/category_family"
            android:parentactivityName="com.example.android.miwok.Mainactivity" >

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_actIVITY"
                android:value=".Mainactivity" />
        </activity>
        <activity
            android:name="com.example.android.miwok.Colorsactivity"
            android:label="@string/category_colors"
            android:parentactivityName="com.example.android.miwok.Mainactivity" >

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_actIVITY"
                android:value=".Mainactivity" />
        </activity>
        <activity
            android:name="com.example.android.miwok.Phrasesactivity"
            android:label="@string/category_phrases"
            android:parentactivityName="com.example.android.miwok.Mainactivity" >

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_actIVITY"
                android:value=".Mainactivity" />
        </activity>
    </application>

</manifest>

Mainactivity.java:

/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License,Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,software
 * distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.android.miwok;

import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatactivity;
import android.view.View;


public class Mainactivity extends AppCompatactivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Set the content of the activity to use the activity_main.xml layout file
        setContentView(R.layout.activity_main);
    }
    public void OpenNumbersList(View view)
    {
    }
}

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project

     Licensed under the Apache License,Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing,software
     distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/tan_background"
    android:orientation="vertical"
    tools:context="com.example.android.miwok.Mainactivity">

    <TextView
        android:id="@+id/numbers"
        style="@style/CategoryStyle"
        android:background="@color/category_numbers"
        android:text="@string/category_numbers" />

    <TextView
        android:id="@+id/family"
        style="@style/CategoryStyle"
        android:background="@color/category_family"
        android:text="@string/category_family" />

    <TextView
        android:id="@+id/colors"
        style="@style/CategoryStyle"
        android:background="@color/category_colors"
        android:text="@string/category_colors" />

    <TextView
        android:id="@+id/phrases"
        style="@style/CategoryStyle"
        android:background="@color/category_phrases"
        android:text="@string/category_phrases" />

</LinearLayout>

tyh012 回答:我该如何解决此错误?资源链接失败

您可能已复制并粘贴了git存储库“ https://github.com/udacity/ud839_Miwok/tree/Starter-code”中的所有代码。而不是复制和粘贴,请在字符串值内输入(例如,“ @字符串/类别编号”)。AndroidManifest.xml文件中。您看到此错误,因为Android Studio无法识别它。 确保res文件夹中的strings.xml文件完整。

本文链接:https://www.f2er.com/3167179.html

大家都在问