簡體   English   中英

在'android'包中找不到屬性'appComponentFactory'的資源標識符

[英]No resource identifier found for attribute 'appComponentFactory' in package 'android'

我使用谷歌材料設計作為這個https://material.io/develop/android/docs/getting-started/但是當同步項目我有以下錯誤

在'android'包中找不到屬性'appComponentFactory'的資源標識符消息{kind = ERROR,text =在'android'包中找不到屬性'appComponentFactory'的資源標識符,sources = [\\?\\ E:\\ Projects \\ xoxo- android \\ app \\ build \\ intermediates \\ manifests \\ full \\ debug \\ AndroidManifest.xml:17],原始消息=,工具名稱= Optional.of(AAPT)}

這是我的build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        applicationId "com.example.official2.xoxo"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'org.apache.httpcomponents:httpclient:4.5'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:design:26.0.1'
    compile 'com.google.android.gms:play-services-appindexing:8.1.0'
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
    compile 'com.wang.avi:library:2.1.3'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    compile 'com.droidninja:filepicker:1.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:cardview-v7:26.0.1'
    compile 'com.github.ganfra:material-spinner:1.1.1'
    compile 'com.google.android.material:material:1.0.0-alpha1'
}

這是manifest.xml文件

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

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="26" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />

    <application
        android:name="droidninja.filepicker.FilePickerDelegate"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.official2.xoxo.activity.LoginActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustPan" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.official2.xoxo.activity.RegisterActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name="com.example.official2.xoxo.MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop" />
        <activity
            android:name="com.example.official2.xoxo.activity.RegisterInfo"
            android:screenOrientation="portrait" />
        <activity android:name="com.example.official2.xoxo.activity.Registration_shop" />
        <activity
            android:name="com.example.official2.xoxo.activity.Product_Dashboard"
            android:label="@string/title_activity_product__dashboard"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity android:name="com.example.official2.xoxo.activity.AddService" />

        <!--
 ATTENTION: This was auto-generated to add Google Play services to your project for
     App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information.
        -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity android:name="com.example.official2.xoxo.activity.SellerProfile" />
        <activity android:name="com.example.official2.xoxo.activity.Services" />
        <activity
            android:name="com.example.official2.xoxo.activity.AddProduct"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateVisible|adjustResize" />
        <activity
            android:name="com.example.official2.xoxo.activity.ProductProfileActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.example.official2.xoxo.activity.AddImagesActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name="droidninja.filepicker.FilePickerActivity"
            android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
        </activity>

        <meta-data
            android:name="android.support.VERSION"
            android:value="26.0.1" />
    </application>

</manifest>

如何修復此錯誤?

試試這段代碼:

cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.+

我有同樣的錯誤。 在我的情況下,它是由+ (即"com.android.support:support-v4:27+" )指定的依賴項引起的,這使得它在使用API​​級別27時使用Android P依賴項。

用特定版本替換它們(例如"com.android.support:support-v4:27.1.1" )解決了錯誤

對Armysir的答案的一個小修正。 我用了這個步驟:

1.將這些行添加到app / build.gradle:

configurations.all {
  resolutionStrategy.force 'com.android.support:support-v4:26.1.0'
}

2.在AndroidManifest.xml文件中,在application-tag中添加一行:

tools:remove="android:appComponentFactory"

失敗的原因

com.google.android.material:materialandroidx一部分,你不能在同一個項目中同時使用支持庫和androidx Android版本不會在版本28.0.0之后更新支持庫。

請參閱@ Android support 28.0.0發行說明

這將是android.support包裝下的最后一個功能版本,鼓勵開發人員遷移到AndroidX 1.0.0

對我來說,解決方案是將我的應用程序遷移到androidx 我發布了一個理解和遷移androidx包的答案 官方遷移文檔也寫得很好。

要么

您可以將這些行放到gradle.properties文件中。

android.useAndroidX = true
android.enableJetifier = true

我面臨同樣的錯誤。需要2天:(

轉到文件 ==> 設置 ==> 構建,執行,部署 ==> Gradle ==>刪除脫機工作的標記

我希望它對你有所幫助

我在react-native項目上遇到此錯誤,並將graogle.properties添加到Google Play版本代碼中。

googlePlayServicesVersion=12.0.1

試過@Hudson答案但沒有奏效。 然后發現這個問題是因為FCM插件,所以我刪除了插件並添加了更新的插件然后再次構建。

cordova plugin remove cordova-plugin-fcm

cordova plugin add https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated

我解決了這個問題:

1.將這些代碼添加到app / build.gradle:

configurations.all {
   resolutionStrategy.force 'com.android.support:support-v4:26.1.0' // old dependencies version;       
}

2.修改了sdk和工具版本到28:

compileSdkVersion 28
buildToolsVersion '28.0.3'
targetSdkVersion  28

2.在AndroidManifest.xml文件中,您應該添加兩行:

<application
    android:name=".YourApplication"
    android:appComponentFactory="any strings be placeholder"
    tools:replace="android:appComponentFactory"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM