在'android'包中找不到属性'appComponentFactory'的资源标识符

Cha*_*ndu 32 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'
}
Run Code Online (Sandbox Code Playgroud)

这是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>
Run Code Online (Sandbox Code Playgroud)

如何修复此错误?

小智 16

试试这段代码:

cordova插件添加cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION = 27. +


小智 12

我有同样的错误.在我的情况下,它是由一个+(即"com.android.support:support-v4:27+")使用API​​级别27使用Android P依赖项指定的依赖项引起的.

用特定版本(例如"com.android.support:support-v4:27.1.1")替换它们解决了错误


Khe*_*raj 5

失败原因

com.google.android.material:material是的一部分androidx,您不能同时使用支持库和androidx同一项目。在28.0.0版之后,Android将不会更新支持库。

请参阅@Android支持28.0.0发行说明

这将是android.support包装下的最后一个功能版本,鼓励开发人员迁移到AndroidX 1.0.0。

对我来说,解决方案是将我的应用迁移到androidx。我发布了一个理解和迁移软件包的答案androidx官方的迁移文档也写得很好。

要么

您可以将这些行gradle.properties归档。

android.useAndroidX = true
android.enableJetifier = true
Run Code Online (Sandbox Code Playgroud)


小智 5

对Armysir的答案有一个小修正。我使用了以下步骤:

1.将以下行添加到您的app / build.gradle中:

configurations.all {
  resolutionStrategy.force 'com.android.support:support-v4:26.1.0'
}
Run Code Online (Sandbox Code Playgroud)

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

tools:remove="android:appComponentFactory"
Run Code Online (Sandbox Code Playgroud)

  • 我认为最好解释一下添加“ configuration.all”代码块的确切位置。它应该在```allprojects {Repositories {.... here}}``内部 (3认同)
  • 另外,在AndroidManifest.xml的&lt;manifest&gt;标记中添加xmlns:tools =“ http://schemas.android.com/tools”。 (2认同)