2

I am working on native android project, I am migrating project code from support library to AndroidX.After that I have also fixed code related issue manually which are not fixed automatically by studio using Migate To AndroidX option.

After upgrading project code to AndroidX getting build errors for drawable.xml files.

here is screenshot of build error:

build error image

  [1]: https://i.stack.imgur.com/OtHE5.png



**Project level build gradle :**

buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
//            name 'Google'
        }

    }
    dependencies {

        classpath 'com.android.tools.build:gradle:4.1.2' //4.1.2 //3.0.0
        classpath 'com.google.gms:google-services:4.0.1'
        classpath "io.realm:realm-gradle-plugin:2.2.1"
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        //        maven {
        maven {
            url 'https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/'
        }
        //        }
        maven { url 'https://maven.google.com/' }

        

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ext{
    // Sdk and tools
    minSdkVersion = 21
    targetSdkVersion = 29
    compileSdkVersion = 29
    gmsVersion = "16.1.0"


}


**App level build.gradle file :**

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

buildscript {
    repositories {
      //  maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
       // classpath 'io.fabric.tools:gradle:1.+'
    }
}

//apply plugin: 'io.fabric'

repositories {
    //maven { url 'https://maven.fabric.io/public' }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

android {
    useLibrary 'org.apache.http.legacy'
    signingConfigs {
        
    }

    lintOptions {
        abortOnError false
        checkReleaseBuilds false
        disable 'InvalidPackage'
    }

    buildTypes {
        release {

            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguardrules.pro'
            signingConfig signingConfigs.config
        }
        debug {

            debuggable true
            signingConfig signingConfigs.config
        }
    }

    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        applicationId "com.app.homemade"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
//        versionCode 21
//        versionName "2.0"
        versionCode 21
        versionName "2.1"
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        multiDexEnabled true
        signingConfig signingConfigs.config
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
    productFlavors {
    }


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/proguard/androidx-annotations.pro' //added

    }


    compileOptions {
//        sourceCompatibility JavaVersion.VERSION_1_7
//        targetCompatibility JavaVersion.VERSION_1_7
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    sourceSets {
        main {
            assets.srcDirs = ['src/main/assets', 'src/main/assets/fonts']
            resources.srcDirs = ['src/main/resources', 'src/main/java/org.jivesoftware.smack']
        }
    }

}

repositories {
    jcenter()
    mavenCentral()
    maven { url "https://jitpack.io" }
    flatDir {
        dirs 'libs'
    }
}

configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'


    implementation 'com.google.android.gms:play-services-auth:16.0.1' //16.0.1
    implementation "com.google.android.gms:play-services-maps:$rootProject.ext.gmsVersion"
    implementation 'com.google.android.gms:play-services-location:16.0.0' //16.0.0
    implementation 'com.google.android.gms:play-services-places:16.0.0' //16.0.0
//    implementation 'com.google.android.gms:play-services-vision:16.2.0'

    implementation 'com.google.firebase:firebase-core:17.5.1'
    implementation 'com.google.firebase:firebase-iid:17.1.0' //17.1.0

    implementation 'com.google.firebase:firebase-auth:16.0.4' //16.0.4
    implementation 'com.google.firebase:firebase-messaging:17.4.0' //17.4.0
    implementation 'com.google.firebase:firebase-crash:16.2.1'
    implementation 'com.braintreepayments.api:drop-in:3.7.1' //5.1.0

    implementation project(':chatinterface')
    implementation project(':library')
    implementation project(':jiaozivideoplayer')
    implementation project(':cropper')


    implementation 'io.pristine:libjingle:9690@aar'
    implementation 'androidx.multidex:multidex:2.0.1' //1.0.1
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'com.github.CiaoIM:emojicon:v1.0.1'
    implementation 'com.romainpiel.shimmer:library:1.4.0@aar'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.1.+' //1.1.+
    implementation 'com.github.danielnilsson9:color-picker-view:1.4.0@aar'
    implementation 'com.nineoldandroids:library:2.4.0+' //2.4.0+
    implementation 'com.github.chrisbanes:PhotoView:1.2.6'

    implementation 'com.squareup.picasso:picasso:2.5.2' //2.5.2
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'io.realm:android-adapters:1.3.0@aar'
    implementation 'com.googlecode.libphonenumber:libphonenumber:7.4.3'
    implementation 'org.apache.httpcomponents:httpmime:4.2.1' //4.2.1
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.squareup.retrofit:retrofit:1.6.1'
    implementation 'com.google.code.gson:gson:2.3' //2.3
    implementation 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
    implementation 'com.squareup.okhttp:okhttp:2.0.0'
    implementation 'log4j:log4j:1.2.17'
//    compile 'com.facebook.android:facebook-android-sdk:4.22.0'
    implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
    implementation 'com.loopj.android:android-async-http:1.4.9'

    implementation 'com.googlecode.mp4parser:isoparser:1.1.20'
    implementation 'com.anjlab.android.iab.v3:library:1.0.44'
    implementation "com.andkulikov:transitionseverywhere:1.8.0"
    implementation 'de.hdodenhof:circleimageview:2.1.0' //2.1.0
    implementation 'io.branch.sdk.android:library:5.+' //5.+
    implementation 'com.nabinbhandari.android:permissions:3.8'    

    implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'     

//    compile('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
//        transitive = true;
//    }

}

apply plugin: 'com.google.gms.google-services'


**Gradle wrapper properties :**

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

**gradle properties:**

org.gradle.jvmargs=-Xmx4608m -Duser.country=US -Duser.language=en
android.useAndroidX=true
android.enableJetifier=true

**tried below solutions but not worked for me:**

1. https://stackoverflow.com/questions/58084850/how-to-fix-this-error-a-failure-occurred-while-executing-com-android-build-grad

2. Created drawable-v24 folder and pasted drawables.xml resources as mentioned below
https://stackoverflow.com/questions/50079312/resource-drawable-not-found


Please let me know any solutions.
Sunil
  • 21
  • 3

0 Answers0