简体   繁体   中英

How can i made my app run and solve this error

I was making mobile app on android, and get some really some errors, that i wasn't available to solve. First error was like this

my gradle for app is

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'

i added

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

also add

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

and

 multiDexEnabled true

Upgraded support to 25.3.1 from 25.0.1 and design same way because it recommended to me after adding multidex 1.0.1 What do I need to do? Press on upgrade plugin does nothing. A day ago, I pushed into github full project, so if it needed here you go

also, it took some error kinda

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzf.class than ppl tell me to clead-rebuild project, so it now sayng like

(30, 1) A problem occurred evaluating project ':app'. > Could not find method exclude() for arguments [{group=com.android.support, module=support-v7}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDe‌​pendencyHandler. so i make change to

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

but now it's tale me

 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 object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDe‌​pendencyHandler. Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager

but they all was installed! so I'm not sure if I change some problems, or just adding new ones. Please help me out.

EDIT Now after first answer my gradle is:

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'

and I have this error

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzf.class

When you braces to add a closure to Gradle, you need to use parentheses around the preceding argument.

IOW, replace:

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

with:

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

and replace:

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

with:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM