如何让我的应用运行并解决此错误

时间:2017-07-18 13:00:33

标签: java android android-studio gradle

我在Android上制作移动应用程序,并得到一些真正的错误,我无法解决。 第一个错误就像 this

我的gradle for app是

apply plugin: 'com.android.application'
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.example.dygy.chat"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true






    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    exclude group: 'com.android.support', module: 'support-v7'
    testCompile 'junit:junit:4.12'
}
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'
    })




    //Add Library
    compile 'com.android.support:design:25.3.1'
    compile 'com.firebaseui:firebase-ui:0.6.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.google.firebase:firebase-storage:10.0.1'
    compile 'com.google.firebase:firebase-config:10.0.1'
    compile 'com.google.firebase:firebase-crash:10.0.1'
}
apply plugin: 'com.google.gms.google-services'

我添加了

exclude group: 'com.android.support', module: 'support-v7+'

还要添加

compile 'com.android.support:multidex:1.0.1'

 multiDexEnabled true

从25.0.1升级对25.3.1的支持并设计相同的方式,因为它在添加multidex 1.0.1后向我推荐了我需要做什么?按升级插件无效。前一天,我推进了github完整项目,所以如果它需要here you go

另外,它有点错误

  

错误:任务执行失败   ':应用程序:transformClassesWithJarMergingForDebug&#39 ;. >   com.android.build.api.transform.TransformException:   java.util.zip.ZipException:重复条目:   COM /谷歌/机器人/克/ AUTH / API /登入/内部/ zzf.class   比ppl告诉我clead-rebuild项目,所以它现在说像

     

(30,1)评估项目':app'时出现问题。 >找不到   方法exclude()for arguments [{group = com.android.support,   在类型的对象上的module = support-v7}]   org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDe pendencyHandler。   所以我改变了

 compile 'com.android.support:appcompat-v7:25.3.1' {
        exclude group: 'com.android.support', module: 'support-v7'
    }

但是现在它给我讲故事

Error:(29, 0) Could not find method com.android.support:appcompat-v7:25.3.1() for arguments
     

[build_kymyozhw5iecrml565pxornd $ _run_closure2 $ _closure7 @ 3e83 7d7] on   对象类型   org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDe pendencyHandler。   请从Android SDK安装Android支持存储库   经理。打开Android SDK Manager

但他们都安装了!所以我不确定我是否改变了一些问题,或者只是添加新问题。请帮帮我。

修改 现在,在第一次回答我的gradle后:

apply plugin: 'com.android.application'
android {

    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.example.dygy.chat"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true






    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile ('com.android.support:appcompat-v7:25.3.1') {
        exclude group: 'com.android.support', module: 'support-v7'
    }
    testCompile 'junit:junit:4.12'
}
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'
    }
    //Add Library
    compile 'com.android.support:design:25.3.1'
    compile 'com.firebaseui:firebase-ui:0.6.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.google.firebase:firebase-storage:10.0.1'
    compile 'com.google.firebase:firebase-config:10.0.1'
    compile 'com.google.firebase:firebase-crash:10.0.1'
}
apply plugin: 'com.google.gms.google-services'

我有这个错误

  

错误:任务执行失败   ':应用程序:transformClassesWithJarMergingForDebug'

     
    

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:     COM /谷歌/机器人/克/ AUTH / API /登入/内部/ zzf.class

  

1 个答案:

答案 0 :(得分:2)

当您支持向Gradle添加闭包时,您需要在前面的参数周围使用括号。

IOW,替换:

compile 'com.android.support:appcompat-v7:25.3.1' {
    exclude group: 'com.android.support', module: 'support-v7'
}

使用:

compile ('com.android.support:appcompat-v7:25.3.1') {
    exclude group: 'com.android.support', module: 'support-v7'
}

并替换:

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

使用:

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
    exclude group: 'com.android.support', module: 'support-annotations'
}