Подтвердить что ты не робот

Создание приложения для Android с targetSdkVersion 25 и minSdkVersion 19

У меня есть приложение для Android с targetSdkVersion от 25. Он отлично работает на API 21 +, однако я пытаюсь исправить его для запуска на API 19 + (KitKat). Мое приложение действительно использует Material Design, который, как мне известно, был представлен в API 21, однако я видел здесь, что должны быть способы вернуть его обратно.

Однако, когда я строю и запускаю, я получаю сообщение об ошибке:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/activation/MimeTypeParseException.class

когда я запускаю эмулятор KitKat.

Кто-нибудь видел эту ошибку раньше, когда вы пытаетесь протестировать свои приложения с помощью back-version?

В моем файле gradle есть:

compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:percent:25.0.0'
compile 'com.android.support:palette-v7:25.0.0'
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:support-v13:25.0.0'

Какую дополнительную информацию я могу предоставить, чтобы помочь отладить это?

Обновление Полный код gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'idea'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'

android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/mimetypes.default'
    }
    compileSdkVersion 25
    buildToolsVersion '25.0.0'
    defaultConfig {
        applicationId "com.ohmd.ohmd"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 10
        versionName "2.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
        renderscriptTargetApi 25
        renderscriptSupportModeEnabled true
    }
    dataBinding {
        enabled = true
    }
    lintOptions {
        abortOnError false
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            debuggable true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            debuggable true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    compileSdkVersion 25
}


idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

repositories {
    jcenter()
    maven { url 'http://repo1.maven.org/maven2' }
    maven { url "https://maven.java.net/content/groups/public/" }
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
}


configurations.all {
    resolutionStrategy {
        force 'junit:junit:4.12'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'net.sf.flexjson:flexjson:2.1'
    compile('org.apache.abdera:abdera-i18n:1.1.1') {
        exclude module: 'support-v4'
    }
    compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.0') {
        exclude module: 'support-v4'
        transitive=true
    }
    compile('org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0') {
        exclude module: 'support-v4'
    }

    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:percent:25.0.0'
    compile 'com.android.support:palette-v7:25.0.0'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.android.support:support-annotations:25.0.0'
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.sun.mail:android-mail:1.5.6'
    compile 'com.sun.mail:android-activation:1.5.6'
    compile 'com.afollestad.material-dialogs:core:0.9.0.2'
    compile 'com.afollestad.material-dialogs:commons:0.9.0.2'
    compile 'com.code-troopers.betterpickers:library:3.0.1'
    compile 'commons-codec:commons-codec:1.10'
    compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
    compile 'com.joanzapata.iconify:android-iconify-material:2.2.2'
    compile 'com.joanzapata.iconify:android-iconify-material-community:2.2.2'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.github.satyan:sugar:1.5'
    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
    compile 'com.github.boxme:asyncmanager:1.0.0'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.makeramen:roundedimageview:2.2.1'
    compile 'joda-time:joda-time:2.9.5'
    compile 'com.android.support:recyclerview-v7:25.0.0'
    compile 'com.github.stfalcon:frescoimageviewer:0.3.1'
    compile 'joda-time:joda-time:2.9.6'
    compile 'com.liuzhuang.opensource:rcimageview:0.0.2'
    compile 'com.uncopt:android.justified:1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.auto.value:auto-value:1.2'
    compile 'com.karumi:dexter:2.3.0'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.1.6'
    compile 'com.google.auto.value:auto-value:1.2'
    compile 'com.googlecode.libphonenumber:libphonenumber:7.2.2'
    compile 'com.github.siyamed:android-shape-imageview:[email protected]'
    compile 'com.github.nekocode:Badge:1.6.2'
    compile 'com.sjl:Foredroid:1.0.0'
    compile 'com.kaopiz:kprogresshud:1.0.5'
    compile 'com.wang.avi:library:2.1.3'
    compile 'kr.pe.burt.android.lib:androidoperationqueue:0.0.2'
    apt "com.google.auto.value:auto-value:1.2"
    compile 'com.ryanharter.auto.value:auto-value-parcel:0.2.4-rc2'
    apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.4-rc2'
    compile 'jp.wasabeef:recyclerview-animators:2.2.5'
    compile 'me.leolin:ShortcutBadger:[email protected]'
    compile 'com.cocosw:bottomsheet:[email protected]'
    compile 'com.github.tajchert:nammu:1.1.1'
    compile('com.frosquivel:magicalcamera:[email protected]') {
        transitive = false;
    }

    // Circular progress bar
    compile 'com.github.castorflex.smoothprogressbar:library-circular:1.2.0'

    // Google Play services (old versions, but they work)
    compile 'com.google.android.gms:play-services:6.5.87'

    // Secure shared preferences
    compile 'online.devliving:securedpreferencestore:0.2.4'

    // Included libraries
    compile project(':animation-core')
    compile project(':animation-abslistview')
    compile project(':animation-circular-progress-button')

    // Fabic
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:answers:[email protected]') {
        transitive = true;
    }

    // Segment
    compile 'com.segment.analytics.android:analytics:4.+'

    // Test components
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test:rules:0.5'
    androidTestCompile 'com.android.support:support-annotations:25.0.0'
    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-intents:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestCompile('com.android.support.test.espresso:espresso-web:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
}

Обновление 2

Я смог повторить эту точную ошибку, запустив новое приложение Android от Android Studio 2.2.2 и используя вышеуказанный файл gradle. Таким образом, это не имеет ничего общего с фактическим кодом внутри моего приложения (что неудивительно).

4b9b3361

Ответ 1

решаемые. Преступниками были:

compile 'com.sun.mail:android-mail:1.5.6'
compile 'com.sun.mail:android-activation:1.5.6'

Я понятия не имею, почему, но удаление этих двух пакетов позволило запустить и развернуть все приложение до < 21.

Ответ 2

Вчера я проверил gradle, который я попросил, и я удалил следующие строки compile 'com.sun.mail:android-mail:1.5.6', compile 'com.sun.mail:android-activation:1.5.6' и скомпилировал. Он не имеет ничего общего с уровнями api. Это происходит потому, что есть еще один модуль, кроме того, который вы удалили, который использует тот же пакет с тем же классом avax/activation/MimeTypeParseException.class. Вы добавили следующее в свой класс приложения?

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

Ответ 3

Вы не можете добавить две библиотеки поддержки, поскольку они перекрывают друг друга. Просто используйте один: support-v4.

Ответ 4

Вам нужно попытаться использовать Библиотека аннотаций поддержки вместо аннотации jetbrains. Поэтому измените

compile 'org.jetbrains:annotations-java5:15.0'

to

compile 'com.android.support:support-annotations:25.0.0'

Затем используйте, Для аннотации @Nullable:

import android.support.annotation.Nullable;

Для @NonNull:

import android.support.annotation.NonNull;

Дополнение:
Не забудьте изменить buildToolsVersion, targetSdkVersion, compileSdkVersion и Support Library, чтобы использовать тот же уровень API.


UPDATE
Вам нужно удалить плагин apt и использовать annotationProcessor, поскольку документация android-apt говорит:

От apt до annotationProcessor

С плагином Android Gradleверсии 2.2, все функции, которые ранее были предоставлены android-apt теперь доступен в Android-плагине. Это значит, что android-apt официально устарел;) Вот шаги для миграции:

  • Убедитесь, что вы используете плагин Android Gradle 2.2 или новее.
  • Удалите плагин android-apt из скриптов сборки
  • Измените все зависимости apt, androidTestApt и testApt к их новому формату:

    dependencies {
        compile 'com.google.dagger:dagger:2.0'
        annotationProcessor 'com.google.dagger:dagger-compiler:2.0' 
    }
    

Также удалите apt-плагин из файла build.gradle i.e:

apply plugin: 'com.neenbedankt.android-apt'

Удалите повторяющийся ввод joda-time, используйте только один из них:

compile 'joda-time:joda-time:2.9.5'
compile 'joda-time:joda-time:2.9.6'

Предложение:
Вам нужно удалить некоторую библиотеку, которая имеет аналогичную цель, подобную этой:

compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.liuzhuang.opensource:rcimageview:0.0.2'
compile 'com.github.siyamed:android-shape-imageview:[email protected]'

Выберите только тот, который действительно подходит для ваших нужд. Не тратьте свое драгоценное время на проверку для всех.

Кроме того, вам нужно выбрать только одну следующую библиотеку изображений:

compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.stfalcon:frescoimageviewer:0.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'