Google and Huawei APK flavor build issue

1.3k views Asked by At

I setup my project for flavors build (Google & Huawei) according to this doc - https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-config-flavor.

Here are my build scripts. I have tried including the signature in the release build with no change.

app build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "com.myapp.testapp"
    }

    flavorDimensions "platform"
    productFlavors {
        huawei {
            versionCode 1712
            versionName "1.7.12"
            targetSdkVersion 29
            minSdkVersion 26
            buildTypes {
                resValue("string", "ad_app_id", "103959507")
                release {
                    resValue("string", "ad_id", "g87ta7hatb")
                    minifyEnabled true
                    proguardFiles 'proguard.cfg'
                    debuggable = true
                }
                debug {
                    resValue("string", "ad_id", "testf9tx29xur5")
                    debuggable = true
                }
            }
        }
    }
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildToolsVersion '29.0.2'
}

dependencies {
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.arch.core:core-runtime:2.1.0'
    implementation 'androidx.arch.core:core-common:2.1.0'

    huaweiImplementation 'com.huawei.hms:ads-lite:13.4.32.300'
    huaweiImplementation 'com.huawei.agconnect:agconnect-apms:1.3.1.300'
    huaweiImplementation 'com.huawei.agconnect:agconnect-core:1.4.1.300'
    huaweiImplementation 'com.huawei.agconnect:agconnect-crash:1.4.1.300'
    huaweiImplementation 'com.huawei.hms:iap:5.0.1.300'
}

apply plugin: 'com.huawei.agconnect'

project build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://developer.huawei.com/repo/'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.huawei.agconnect:agcp:1.3.0.300'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://developer.huawei.com/repo/'
        }
    }
}

The environment is failing with 60054: url is null. The gradle build is also picking up the file location: --W- The variant: huaweiRelease, Use the json file: /Users/xxx/Documents/myappGoogle/app/src/release/agconnect-services.json

I have tried the flavor tags and have tried placing the json file within the flavor directory as the post stated here - https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201313999391430187&fid=0101187876626530001. The file so far has been picked up when placed in the app directory, the src/debug(release) directories, and also in the src/flavor directories. I can clearly see in the build logs that the correct file is being found by the build script.

What's also odd to me is the documentation: https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-ExceptionHandlingAndGeneralErrorCodes-v4 says that 60054 is iap is not supported in this country, but the actual code is returning 60054: url is null.

The error code being returned, iapApiException.getStatus() is returning status.statusCode = 60054 and status.getStatusMessage = "url is null". This is from isEnvReady which is in contradiction to the aforementioned documentation in which status code 60054 should be OrderStatusCode.ORDER_ACCOUNT_AREA_NOT_SUPPORTED where as if this was actually a url error I would expect error 60001 OrderStatusCode.ORDER_STATE_PARAM_ERROR or something along those lines.

I am thinking of the possibility with merge issue due to this document: https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/Environment_installation The reason for my suspicion is that my AndroidManifest is clearly missing the appid that is supposed to be included through the scripts.

Am I missing something here? What is your suggestion or what else should I look into? Thanks.

2

There are 2 answers

0
zhangxaochen On

1.Please check whether you have copy the agconnect-services.json file to the folder of each build type. 2.Please check whether you have modify configuration files to adapt to multiple flavors.

For details, see the documentation.

The result code of 60054 may be returned when HUAWEI IAP is supported by a country or region but there is a service error. In this case:

  1. Please provide your appid to check the info.
  2. Please provide full log: adb logcat >xxx.log to obtain it.
0
Zinna On

This is not the issue with the flavor build but it is the issue with using USA HUAWEI ID in testing. The right solution is a developer should create another non-USA HUAWEI ID and then log into the phone. After opening App Gallery App, change the Settings of country to a country that supports IAP(for example like UK). Remove USA SIM card and then use the IAP service after connecting to the changed country in the Setting using VPN.