Google和华为APK风味构建问题

时间:2020-10-01 06:25:03

标签: huawei-mobile-services huawei-developers android-build-flavors appgallery huawei-iap

我根据此文档https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-config-flavor设置了我的项目以进行风味构建(Google和华为)。

这是我的构建脚本。我尝试不加更改地将签名包含在发行版本中。

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

环境因60054: url is null而失败。 gradle构建还可以选择文件位置: --W- The variant: huaweiRelease, Use the json file: /Users/xxx/Documents/myappGoogle/app/src/release/agconnect-services.json

我已经尝试了风味标签,并尝试将json文件放置在风味目录中,如此处所述-https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201313999391430187&fid=0101187876626530001。到目前为止,该文件已放置在app目录,src / debug(release)目录以及src / flavor目录中,并且已经被拾取。我可以在构建日志中清楚地看到构建脚本可以找到正确的文件。

对我来说,文档也很奇怪: https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-ExceptionHandlingAndGeneralErrorCodes-v460054 is iap is not supported in this country,但实际代码正在返回60054: url is null

返回的错误代码iapApiException.getStatus() 正在返回status.statusCode = 60054status.getStatusMessage = "url is null"。 这来自isEnvReady,这与前述文档中的状态代码60054应该为OrderStatusCode.ORDER_ACCOUNT_AREA_NOT_SUPPORTED相矛盾 好像这实际上是一个网址错误,我会期望错误60001 OrderStatusCode.ORDER_STATE_PARAM_ERROR 或类似的东西。

由于此文档,我正在考虑合并问题的可能性: https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/Environment_installation 我怀疑的原因是我的AndroidManifest明显缺少应该通过脚本包含的appid。

我在这里想念什么吗?您有什么建议或我还应该考虑什么?谢谢。

2 个答案:

答案 0 :(得分:0)

1。请检查是否已将 agconnect-services.json 文件复制到每种构建类型的文件夹中。 2.请检查是否有修改配置文件以适应多种口味。

有关详细信息,请参见documentation

当一个国家或地区支持HUAWEI IAP时,可能会返回60054的结果代码,但服务错误。在这种情况下:

  1. 请提供您的appid来检查信息。
  2. 请提供完整的日志:adb logcat >xxx.log

答案 1 :(得分:0)

这不是风味构建的问题,而是在测试中使用USA HUAWEI ID的问题。正确的解决方案是,开发人员应创建另一个非美国HUAWEI ID,然后登录手机。打开App Gallery App后,将“国家/地区”的设置更改为支持IAP的国家/地区(例如,英国)。在“使用VPN进行设置”中连接到更改的国家/地区后,请删除USA SIM卡,然后使用IAP服务。

相关问题