Cannot create variant 'android-manifest-metadata'

喜夏-厌秋 提交于 2020-08-03 14:20:39

问题


I uploaded my app on Playstore (bundle.aab method) and it works fine with no errors on android 6.0 but got error on android 7.0 device and doens't run the app. I used the Gradle build classpath 3.1.0 - Trying to solve the problem by updating the Gradle version build to 3.2.0-alpha14' so the compile failed giving me the error message bellow. Does anyone know how may I fix this to make my app run on Android 7.0 devices with Gradle 4.7? Perhaps this upgrade fix the device error I think. Thank you!

apply plugin: 'com.android.application'


repositories {
    mavenLocal()
    maven {
        url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
    }
}

android {
    signingConfigs {
    config {
        keyAlias 'key1'
        keyPassword '*****'
        storeFile file('C:/Users/marco/.android/debug.keystore')
        storePassword 'android'
    }
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
    defaultConfig {
        multiDexEnabled true
        applicationId "net.panomaps"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 63
        versionName "5.3.3"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    javaCompileOptions {
            annotationProcessorOptions {
            includeCompileClasspath true
            }
        }
        vectorDrawables.useSupportLibrary = true
    }
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config
    }
    debug {
        signingConfig signingConfigs.config
    }
}
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support:design:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.0'
        implementation 'com.android.support:support-vector-drawable:27.1.1'
        implementation 'com.google.android.gms:play-services-auth:15.0.1'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.google.firebase:firebase-core:15.0.2'
        implementation 'com.google.firebase:firebase-appindexing:15.0.1'
        implementation 'com.google.firebase:firebase-config:15.0.2'
        implementation 'com.google.firebase:firebase-invites:15.0.1'
        implementation 'pub.devrel:easypermissions:1.1.2'
        implementation 'com.google.firebase:firebase-messaging:15.0.2'
        implementation 'org.xwalk:xwalk_core_library:23.53.589.4'
        implementation 'com.squareup.picasso:picasso:2.5.2'
        implementation 'com.firebaseui:firebase-ui-auth:3.1.3'
        implementation 'com.firebaseui:firebase-ui:3.1.3'
        implementation 'com.google.firebase:firebase-auth:15.1.0'
        implementation 'com.google.firebase:firebase-database:15.0.1'

        implementation 'com.github.Q42:AndroidScrollingImageView:1.3.2'

        implementation 'com.android.support:multidex:1.0.3'
    }

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


    // error message -> Cannot create variant 'android-manifest-metadata' after configuration ':app:debugApiElements' has been resolved

Gradle distributionUrl=https://services.gradle.org/distributions/gradle-4.7-all.zip

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0-alpha14'
    classpath 'com.google.gms:google-services:3.3.0'
    }
}

error message -> Cannot create variant 'android-manifest-metadata' after configuration ':app:debugApiElements' has been resolved


回答1:


The issue is related to the google services

After upgrading the firebase versions and / or the gradle plugin version I also had to upgrade the google services plugin version

dependencies {
    classpath 'com.google.gms:google-services:4.0.1'
} 



回答2:


Had the same issue and was resolved when I updated to the latest versions:

classpath 'com.android.tools.build:gradle:3.3.0-alpha02'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'io.fabric.tools:gradle:1.25.4'



回答3:


Updating to latest versions didn't help. In our case problem was caused by our custom Gradle task that was resolving dependencies during project configuration.

To locate such tasks first run Gradle Build Scan using --scan (e.g. ./gradlew app:assembleDebug --scan). Then go to the generated scan page, Performance -> Settings and suggestions. If there is a warning saying Dependencies were resolved during project configuration then you're about to have some fun fixing those.

In our case, it was a custom task that was accessing variant.javaCompiler.classpath.files during the configuration step. Try searching for configurations. or .files in Gradle scripts to find potential culprits and start with commenting those out and re-running the Build Scan to see if the problem is gone.

Following links might help you understand the problem:

  • https://guides.gradle.org/performance/#don_t_resolve_dependencies_at_configuration_time
  • https://discuss.gradle.org/t/build-scan-argues-about-dependency-resolution-during-project-configuration-may-reduce-build-speed-by-resolving-dependencies-unnecessarily/21583



回答4:


In my case it happens due to plugin:

apply plugin: 'com.orhanobut.tracklytics'

Seems it use deprecated api, so I have removed apply plugin: 'com.orhanobut.tracklytics'



来源:https://stackoverflow.com/questions/50297502/cannot-create-variant-android-manifest-metadata

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!