android - 在设备上运行应用程序时出现 transformClassesWithJarMergingForDebug 错误

标签 android android-studio firebase

我尝试使用 Firebase 平台开发带有通知的简单应用程序。我收到了错误 :app:transformClassesWithDexForDebug,我通过将行 multiDexEnabled true 添加到 build.gradle 中来修复该错误。 编辑后出现错误 :app:transformClassesWithJarMergingForDebug 我的build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android 

    {
        compileSdkVersion 25
        buildToolsVersion "25.0.2"
        defaultConfig {
            applicationId "com.example.jaroslavvystavel.noti"
            minSdkVersion 17
            targetSdkVersion 25
            multiDexEnabled true  // this line will solve this problem
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
            }
            debug {
                debuggable true
            }
        }    
    }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

    compile 'com.google.firebase:firebase-messaging:10.2.1'
}

构建没有问题,当我尝试在连接的手机上运行应用程序时出现问题。当我使用 AVD 时,我收到消息 App has stopped.. 我正在根据本教程开发应用程序 YouTube tutorial

最佳答案

google-servicesapply plugin 必须遵循 dependencies block :

dependencies {
    ...
}
apply plugin: 'com.google.gms.google-services'

Google Services Gradle Plugin 的文档中对此进行了描述.

关于android - 在设备上运行应用程序时出现 transformClassesWithJarMergingForDebug 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43566844/

相关文章:

android - 无法在 Android Studio 中调试 onPostExecute

java - 如何完美捕获o = object.object.object操作中的Java NullPointerException?

Android Studio 3.6 canary 4 - Gradle 抛出 DefaultProjectSyncIssues 异常

java - 如何修复错误包 android.support.v7 不存在?

Android Studio 在提交更改对话框中显示未更改的文件

android - 如何从 firebase 中求和多个值

android - 如何让 Android BroadcastReceiver 与 AlarmManager 配合使用?

java - 如何更改我的 fragment 中的文件 XML 属性

Firebase 托管不生成 firebase.json

android - FirebaseMessagingService 是否默认在后台运行?