android - 生成签名包失败但生成常规包成功 Android Studio

标签 android android-studio react-native

我有一个 React Native (0.59.10) 项目,我想开始使用新的 Google App Signing用于较小构建、下载等的程序。为了注册此程序,我需要从 Android Studio 上传导出的应用签名 key :

Export your key from Android Studio. From the Build menu, select Generate Signed Bundle/APK. Select the Bundle option and press Next. Select Export the encrypted key and press Next.

但是,当我完成这个过程时,它在构建过程中失败并出现以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:preReleaseBuild'.
> Could not resolve all dependencies for configuration ':app:releaseRuntimeClasspath'.
   > java.util.ConcurrentModificationException (no error message)

奇怪的是,如果我只是选择 bundle 应用程序(没有签名),它就可以正常工作。我还可以构建签名的 APK 并将其上传到 Play 商店

./gradlew assembleRelease.

这是我的项目 gradle 文件:

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 19
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
    playServicesVersion = "11.0.2"
}


buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.4.2')
        classpath("com.google.gms:google-services:4.0.1")
        classpath("com.jaredsburrows:gradle-license-plugin:0.8.41")
        classpath("embrace-io:embrace-swazzler:3.1.6")
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion '12.0.1'
                }
                if (requested.group == 'com.google.firebase') {
                    details.useVersion '12.0.1'
                }
                if (requested.group == 'com.android.support') {
                    if (!requested.name.startsWith("multidex")) {
                        details.useVersion "${rootProject.ext.supportLibVersion}"
                    }
                }
            }
        }
    }
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

我尝试过的事情

  • 更新/重新安装 Android 支持 SDK

  • 更新/重新安装 Google 支持 SDK

  • 删除所有包并使用 Yarn 重新安装

  • 升级 Gradle 版本

  • 更新单个 npm 包

  • 清理/重建/使 Android Studio 失效并重启

非常感谢任何帮助或替代解决方案,谢谢!

最佳答案

由于您已经成功创建了一个已签名的发布 APK,我假设您已完成所有 keystore 和签名设置。

我为 Google App Signing 所做的是使用第二个选项(从 Java keystore 导出和上传 key )而不是第一个选项。只需下载 PEPK 工具并按照 Play Store Console 提供的说明进行操作(他们会提供创建您需要上传的文件的命令)。

用于创建包而不是 APK;从 android 文件夹中使用命令

./gradlew bundleRelease

创建的bundle可以在

中找到

android/app/build/outputs/bundle/release/app.aab

这是我上传到 Google Play 的 bundle 文件

关于android - 生成签名包失败但生成常规包成功 Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56998057/

相关文章:

android - 将现有的 Activity 应用程序迁移到 Fragments

android-studio - Android Studio中的“包过滤器删除了所有包”错误

android-studio - Android Studio - 提示使用任何可用的应用程序打开下载的文件

android-studio - 不支持的 gradle 方法 : NativeArtifact. getSourceFolders()

ios - React-native-twitter-signin : ios Undefined symbols for architecture x86_64, 编辑:尝试在没有有效 twitter 工具包 url 方案的情况下登录

reactjs - React Native Expo - Jest - React Native Firebase - 不变违规 : Native module cannot be null

android - 运行适用于 Android 的新英特尔仿真器

android - SQLite - DELETE 命令中没有这样的列

android - 如何从 React Navigation Header Ba 中调用类函数

android - 扩展 ActionBarActivity 时应用程序崩溃