Почему у меня проблема с несколькими файлами dex? - PullRequest
0 голосов
/ 16 декабря 2018

У меня есть эта ошибка

Несколько файлов dex определяют Lcom / google / firebase / iid / zzf;

Пытался исправить много раз, но ни в коем случае не собираю проектную сборку Я смотрю такМного проблем, опубликованных здесь в Stackoverflow, но у меня та же ошибка

allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
    maven {
        url 'https://jitpack.io'
    }
    }
    }

    buildscript {
    dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'

}
repositories {
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    jcenter()
}
}

ext {
supportlib_version = '26.1.0'
gps_version = '11.2.0'
}

//Ensure that all dependencies use the same version of the Android Support 
library
subprojects {
project.configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
                && !details.requested.name.contains('multidex')) {
            details.useVersion "$supportlib_version"
        }
        if (details.requested.group == 'com.google.android.gms'
                && !details.requested.name.contains('multidex')) {
            details.useVersion "$gps_version"
        }
    }
}
}

allprojects {
repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
}

, и мой модуль Gradle менял ее много раз, но я получаю ту же ошибку

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.sherdle.universal"
    minSdkVersion 16
    targetSdkVersion 26
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    //Optionally configure your OneSignal IDs below
    manifestPlaceholders = [manifestApplicationId: "${applicationId}",
                            onesignal_app_id: "",
                            onesignal_google_project_number: ""]
 }
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.txt'
    }
 }
dexOptions {
    jumboMode true
}
}

repositories {
flatDir {
    dirs 'libs'
}
maven {
    url "https://jitpack.io"
}
jcenter();
}

dependencies {
compile 'com.devbrackets.android:exomedia:4.0.3' //TV
compile 'com.google.android.exoplayer:exoplayer:r2.4.3' //TV & Radio
compile 'com.cleveroad:audiovisualization:1.0.0' //Radio
compile 'com.google.code.gson:gson:2.8.0' //WC
compile 'com.squareup.okhttp3:okhttp:3.7.0' //WC
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.onesignal:OneSignal:[3.6.5,4.0.0)'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.duolingo.open:rtl-viewpager:1.0.2'
compile 'com.github.apg-mobile:android-round-textview:v0.0.3'
compile 'com.github.chrisbanes:PhotoView:1.3.0'

compile "com.android.support:cardview-v7:$supportlib_version"
compile "com.android.support:appcompat-v7:$supportlib_version"
compile "com.android.support:recyclerview-v7:$supportlib_version"
compile "com.android.support:design:$supportlib_version"
compile "com.android.support:support-v4:$supportlib_version"
compile "com.android.support:support-core-utils:$supportlib_version"
compile "com.android.support:support-media-compat:$supportlib_version"

compile "com.google.android.gms:play-services-gcm:$gps_version"
compile "com.google.firebase:firebase-common:16.0.4"
compile "com.google.android.gms:play-services-ads:$gps_version"
compile "com.google.android.gms:play-services-maps:$gps_version"
compile 'com.google.maps.android:android-maps-utils:0.5+'
compile files('libs/YouTubeAndroidPlayerApi.jar')

}

Мне действительно нужна ваша поддержкаКроме того, я хочу знать, почему именно эта ошибка именно спасибо

1 Ответ

0 голосов
/ 16 декабря 2018

Вам нужно изменить ваш supportlib_version = '26 .1.0 'на '26 .0.1'

, добавить в ваш gradle:

defaultConfig {
// ...
multiDexEnabled true

}

  compile 'com.android.support:multidex:1.0.3'
  compile 'com.google.android.gms:play-services:12.0.1'
  compile 'com.google.android.gms:play-services-maps:16.0.0'
  compile 'com.google.android.gms:play-services-ads::16.0.0'
  compile 'com.google.android.gms:play-services-gcm:16.0.0'

и добавить configrations.all в ваш gradle:

  configurations.all {
  resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  def requested = details.requested
if (requested.group == 'com.android.support') {
    if (!requested.name.startsWith("multidex")) {
        details.useVersion '26.0.0'
    }
 }
}
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...