33

I used google material design as this https://material.io/develop/android/docs/getting-started/ But when sync project I had following error

No resource identifier found for attribute 'appComponentFactory' in package 'android' Message{kind=ERROR, text=No resource identifier found for attribute 'appComponentFactory' in package 'android', sources=[\?\E:\Projects\xoxo-android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:17], original message=, tool name=Optional.of(AAPT)}

This is my build.gradle file

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'
}

This is manifest.xml file

<?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>

How fix this error?

Chamindu
  • 391
  • 1
  • 4
  • 8
  • The error is in the merged manifest, so it's probably one of your dependencies referencing that resource. Post the contents of the file E:\Projects\xoxo-android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml so we can have a look what the problem is. – Izabela Orlowska May 10 '18 at 15:33
  • Thanks for advice. I was developed this app using default design methods. Anyway when above error occurred, this manifest file had value as 'appComponentFactory'. I opened this manifest file using notepad and removed this 'appComponentFactory' line and saved it. Then i build my app, this error was generated again. And above line had in manifest file again. So I haven't build my code when removing that line. – Chamindu May 14 '18 at 09:00
  • 1
    That file is automatically generated by the gradle plugin, it is a merge of your AndroidManifest and your dependencies' AndroidManifests. That's why when you edit it, it will still get modified and the line will be back there. That line must be coming from one of your dependencies - post the contents so we can figure out which one it is. – Izabela Orlowska May 14 '18 at 10:15
  • 3
    Researching that string it also looks like it's a new ApplicationInfo field, starting with P. Make sure your target API is P (you need to use Android P Developer Preview). – Izabela Orlowska May 14 '18 at 10:18
  • try this https://stackoverflow.com/questions/49249713/cannot-able-to-build-the-project-after-upgrading-to-android-p/52615277#52615277 – hvar90 Oct 03 '18 at 03:31
  • Have you checked this answer : https://stackoverflow.com/a/54825603/1318946 – Pratik Butani Feb 22 '19 at 11:44

7 Answers7

18

Try this code:

cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.+
SystemParadox
  • 8,203
  • 5
  • 49
  • 57
Hudson Ab
  • 197
  • 1
  • 4
13

I had the same error. In my case it was caused by dependencies specified with a + (i.e. "com.android.support:support-v4:27+") making it use Android P dependencies whilst using API level 27.

Replacing them with a specific version (e.g. "com.android.support:support-v4:27.1.1") solved the error

Casper Gerritsen
  • 314
  • 3
  • 13
6

A small fix to Armysir's answer. I used this steps:

1.Add these lines to your app/build.gradle:

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

2.In AndroidManifest.xml file add one line to application-tag:

tools:remove="android:appComponentFactory"
Mikhail
  • 61
  • 1
  • 3
  • 3
    I think its better to explain the exact location to add the ```configuration.all``` code block. Its supposed to be inside the ```allprojects{ repositories{ .... here }}``` – Mutinda Boniface Jan 27 '19 at 09:58
  • 2
    Also, add the xmlns:tools="http://schemas.android.com/tools" in tag in AndroidManifest.xml. – Shyam Jun 22 '19 at 16:57
5

Reason of fail

com.google.android.material:material is part of androidx, and you can not use both support libraries and androidx in same project. Android will not update support libraries after version 28.0.0.

See @Android support 28.0.0 release notes.

This will be the last feature release under the android.support packaging, and developers are encouraged to migrate to AndroidX 1.0.0

Solution

For me solution was to migrate my app to androidx. I posted an answer for understanding and migrating androidx package. Official migrate documentation is also very well written.

Or

You can just put these lines to gradle.properties file.

android.useAndroidX = true
android.enableJetifier = true
Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
4

I faced with the same error.It take 2 day :(

Go to File ==>Settings==>Build,Execution,Deployment ==>Gradle ==>Remove mark of Offline work

I hope it helps you

Abdullah alkış
  • 325
  • 4
  • 13
3

I had this error on react-native project and adding google play version code to gradle.properties worked.

googlePlayServicesVersion=12.0.1

Canbey Bilgili
  • 754
  • 5
  • 12
2

Tried @Hudson answer but didn't work. Then found the issue that is because of FCM plugin, so I removed the plugin & added back with updated one then build again.

cordova plugin remove cordova-plugin-fcm

cordova plugin add https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated
sulaiman sudirman
  • 1,826
  • 1
  • 24
  • 32