【问题标题】:Google and Huawei APK flavor build issue谷歌和华为 APK 风格构建问题
【发布时间】:2020-10-01 06:25:03
【问题描述】:

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

这是我的构建脚本。我已经尝试在发布版本中包含签名而没有任何更改。

应用程序构建.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'

项目构建.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 build 也在获取文件位置: --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 好像这实际上是一个 url 错误我会期望错误 60001 OrderStatusCode.ORDER_STATE_PARAM_ERROR 或类似的东西。

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

我在这里遗漏了什么吗?你的建议是什么,或者我还应该研究什么?谢谢。

【问题讨论】:

  • 你能不能试着把apply plugin: 'com.huawei.agconnect'放在apply plugin: 'com.android.application'下面。

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


【解决方案1】:

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

详情请见documentation

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

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

【讨论】:

    【解决方案2】:

    这不是风味版本的问题,而是在测试中使用美国华为 ID 的问题。正确的解决方案是开发者应创建另一个非美国华为帐号,然后登录手机。打开App Gallery App后,将国家的设置更改为支持IAP的国家(例如英国)。移除美国 SIM 卡,然后在使用 VPN 连接到更改后的国家/地区后使用 IAP 服务。

    【讨论】:

      猜你喜欢
      • 2019-11-02
      • 1970-01-01
      • 2022-08-12
      • 1970-01-01
      • 1970-01-01
      • 2011-07-22
      • 1970-01-01
      • 2021-01-10
      • 1970-01-01
      相关资源
      最近更新 更多