Problem build android after import admob in CC v2.4.3

After i import admob , i build project android and have this error

Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.2.0] AndroidManifest.xml:24:18-86
is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
Suggestion: add ‘tools:replace=“android:appComponentFactory”’ to element at AndroidManifest.xml:7:5-42:19 to override.

I’m trying to fix , i add this code to gradle.properties

android.enableJetifier=true
android.useAndroidX=true

and update build.gradle

classpath ‘com.android.tools.build:gradle:3.3.3’

Now it have this error

Program type already present: com.sdkbox.collection.ImmutableMap

Update after i import admob and facebook social again and i have this error

Program type already present: com.sdkbox.plugin.FacebookShareUnit

Project.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
                dirs 'libs'
        }
    }
}

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

App.gradle:

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

android {
    compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
    buildToolsVersion PROP_BUILD_TOOLS_VERSION

    defaultConfig {
        applicationId "zstudio.game.animaljump"
        minSdkVersion PROP_MIN_SDK_VERSION
        targetSdkVersion PROP_TARGET_SDK_VERSION
        versionCode 7
        versionName "0.0.6"
        multiDexEnabled true
        externalNativeBuild {
            ndkBuild {
                if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
                    // skip the NDK Build step if PROP_NDK_MODE is none
                    targets 'cocos2djs'
                    arguments 'NDK_TOOLCHAIN_VERSION=clang'

                    def module_paths = [project.file("../../../cocos2d-x"),
                                        project.file("../../../cocos2d-x/cocos"),
                                        project.file("../../../cocos2d-x/external")]
                    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                        arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
                    }
                    else {
                        arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
                    }
                    
                    arguments '-j' + Runtime.runtime.availableProcessors()
                    abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
                }
            }
        }
    }

    sourceSets.main {
        java.srcDirs "../src", "src"
        res.srcDirs "../res", 'res'
        jniLibs.srcDirs "../libs", 'libs'
        manifest.srcFile "AndroidManifest.xml"
    }

    externalNativeBuild {
        ndkBuild {
            if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
                // skip the NDK Build step if PROP_NDK_MODE is none
                path "jni/Android.mk"
            }
        }
    }

    signingConfigs {

       release {
            if (project.hasProperty("RELEASE_STORE_FILE")) {
                storeFile file(RELEASE_STORE_FILE)
                storePassword RELEASE_STORE_PASSWORD
                keyAlias RELEASE_KEY_ALIAS
                keyPassword RELEASE_KEY_PASSWORD
            }
        }
    }

    buildTypes {
        release {
            debuggable false
            jniDebuggable false
            renderscriptDebuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            if (project.hasProperty("RELEASE_STORE_FILE")) {
                signingConfig signingConfigs.release
            }

            externalNativeBuild {
                ndkBuild {
                    arguments 'NDK_DEBUG=0'
                }
            }
        }

        debug {
            debuggable true
            jniDebuggable true
            renderscriptDebuggable true
            externalNativeBuild {
                ndkBuild {
                    arguments 'NDK_DEBUG=1'
                }
            }
        }
    }
}

android.applicationVariants.all { variant ->
    // delete previous files first
    delete "${buildDir}/intermediates/merged_assets/${variant.dirName}"

    variant.mergeAssets.doLast {
        def sourceDir = "${buildDir}/../../../../.."

        copy {
            from "${sourceDir}/assets"
            into "${outputDir}/assets"
        }

        copy {
            from "${sourceDir}/src"
            into "${outputDir}/src"
        }

        copy {
            from "${sourceDir}/jsb-adapter"
            into "${outputDir}/jsb-adapter"
        }

        copy {
            from "${sourceDir}/main.js"
            from "${sourceDir}/project.json"
            into outputDir
        }
    }
}

dependencies {
    implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
    implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
    implementation fileTree(dir: "../../../cocos2d-x/cocos/platform/android/java/libs", include: ['*.jar'])
    implementation project(':libcocos2dx')
    implementation "com.zing.zalo.zalosdk:core:2.5.0520"
    implementation "com.zing.zalo.zalosdk:auth:2.5.0520"
    implementation "com.zing.zalo.zalosdk:openapi:2.5.0520"
    implementation 'com.android.installreferrer:installreferrer:1.1'
    implementation 'com.google.android.gms:play-services-analytics:16.0.5'
    implementation 'com.android.support:multidex:1.0.3'

}
dependencies { compile 'com.facebook.android:facebook-android-sdk:5.+' }
dependencies { compile 'com.google.android.gms:play-services-base:16.1.0' }
dependencies { compile 'com.google.android.gms:play-services-ads:19.8.0' }

i need some help, please @htlxyz

Maybe there are two same jars in your project.

You can check folder “framework/runtime-src/proj.android-studio/app/libs”, “framework/runtime-src/proj.android-studio/libs”.
if these two folders have the same jar, please delete one of them.

this is a admob sample if you need, GitHub - sdkbox/sdkbox-sample-ccc200 at admob

and
still can’t solve your problem, please share your project with me.

@htlxyz it pass that error “Program type already present: com.sdkbox.plugin.FacebookShareUnit” , now it have this error
"Error: Program type already present:com.google.android.gms.internal.measurement.zzag"

it’s the same reason.

there have two same gms jar exist.
Or there is a gms jar under libs folder and a gms dependency in app/build.gradle.(remove gms jar, keep gradle’s dependency)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.