android - 华为设备: The meta-data tag in your app's AndroidManifest. xml没有正确的值

标签 android google-play-services manifest huawei-mobile-services

我在一个已经运行了大约 4 年的大量使用应用程序中工作,在上一个版本中实现了一些新库,在实现之后我们在尝试检查 Google Play 服务是否可用时遇到了一些问题,这只发生在搭载 Android 8+ 的华为设备上。 logcat 向我们展示了这个堆栈跟踪

Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 12451000 but found 4323000.  You must have the following declaration within the element:     

我们在 list 上有正确的值:

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="XXXXXXXXXXXXXXXXXXXXXX" />

如果我们按照google_play_services_version的值,我们可以从play-services-basement-16.1.0.aar中找到期望值

<integer name="google_play_services_version">12451000</integer>

这是在gradle上实现的库

implementation "com.android.support.constraint:constraint-layout:$constraint"
implementation "com.android.support:appcompat-v7:$support"
implementation "com.android.support:design:$support"
implementation "com.android.support:cardview-v7:$support"
implementation "com.android.support:recyclerview-v7:$support"
implementation "com.android.support:design:$support"
implementation "com.android.support:support-v4:$support"
implementation "com.android.support:mediarouter-v7:$support" //New Lib
implementation "com.android.support:animated-vector-drawable:$support" //New Lib
implementation "com.android.support:design:$support"
implementation "com.android.support:support-vector-drawable:$support"

//Play services
implementation "com.google.android.gms:play-services-maps:$playServices"
implementation "com.google.android.gms:play-services-analytics:$playServices"
implementation "com.google.android.gms:play-services-gcm:$playServices"
implementation "com.google.android.gms:play-services-safetynet:$playServices"
implementation "com.google.android.gms:play-services-wearable:$playServices"

有了这个版本

ext {
    //build
    sdkCompileVersion = 27
    sdkMinVersion = 16
    sdkTargetVersion = 27
    sdkBuildToolsVersion = '27.0.3'

    //dependencies
    support = '27.1.0'
    playServices = '16.0.0'
    newRelic = '5.18.0'
    constraint = '1.1.2'
}

有没有人知道如何解决这个问题?

最佳答案

您是否在应用程序的任何地方硬编码了 gms 版本的值?像这样的东西 applicationInfo.metaData.putInt("com.google.android.gms.version", 4323000);

您添加的其中一个新库也可能声明了一个旧的/不同的 com.google.android.gms.version

如果仅在华为上发生,则华为可能试图用某些值覆盖。

要确认它是您自己的库还是华为,您必须将其硬编码到 list 中,然后分析您构建的 apk 并检查合并到其中的最终值。如果该值符合预期,则可能是华为在做。

您也可以试试这个链接: https://stackoverflow.com/a/52249677/6668797

如果库使用的是旧的/不同的版本,那么这将用您的版本覆盖它。

如果仍未解决问题,请提供以下详细信息: 请分享完整的堆栈跟踪。 它是否发生在任何 Nexus/Pixel 设备上? 这些库中有哪些是新添加的?

关于android - 华为设备: The meta-data tag in your app's AndroidManifest. xml没有正确的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56397850/

相关文章:

android - Simpleperf 不记录任何样本

java - 从不同 Activity 的 TextView 获取文本

android - 如何让我的应用出现在平板电脑上

android - 对我来说,添加 android :exported ="true" does not solve the problem

java - 禁用 LINT 检查有哪些副作用?

android - 使用 android 和 sdl 从 c++ 进行 java 回调

android - 将 gradle 依赖项 9.4.0 更新到 9.6.1 时构建错误

android - 如何使用 Drive Api.OnSync 完成回调(Android Google Play 服务)

android - 更新播放服务后出错 "Program type already present: com.google.android.gms.internal.measurement.zzabo"

android-emulator - Android 模拟器已过时的 Google Play 服务