java - 生成签名的apk时为"Error: Cannot fit requested classes in a single dex file (# methods: 66653 > 65536)"

标签 java android

我正在尝试生成签名的 apk,以便可以将我的应用导出到 Google Play 商店。但是我不断收到同样的错误。有什么办法可以解决这个问题吗?

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.example.sean.monacoball"
            minSdkVersion 15
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner 
    "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 
    'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'com.android.support:appcompat-v7:12.0.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.gms:play-services:12.0.1'
    }
}

深度错误:

Error

最佳答案

根据 Google Play services setup guide :

Note: Don't use the combined play-services target. It brings in dozens of libraries, bloating your application. Instead, specify only the specific Google Play services APIs your app uses.

当您使用 com.google.android.gms:play-services:12.0.1 时,您将引入所有 Google Play 服务库。您应该切换到仅使用您实际使用的库。这几乎肯定会将您置于 64k method limit 之下单个 dex 文件。

关于java - 生成签名的apk时为"Error: Cannot fit requested classes in a single dex file (# methods: 66653 > 65536)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56382775/

相关文章:

java - Camel 文件消费者不停止

java - 使用 Selenium 获取列表项标题

java - 使用Spring Cloud Stream阅读主题中的所有消息

android - 如何从android中的特定日期获取通话记录

java - 通过正则表达式进行 JTable 单元格验证

android facebook授权(SDK 3.0) FB提示登录两次

java - 无法使用 HttpPost 发布 JSON 数据

java - TextView 数字以波斯字体显示为英文

android - 将 Material Top Tab Navigator 放置在自定义位置

java - 为什么我的服务器 PrintWriter.println() 无法通过套接字发送消息?