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

Invokedynamic требует -min-sdk-version >= 26

Сегодня скачала версию 3.0 beta 2.0 студии, после чего попыталась открыть в ней существующий проект и столкнулась с некоторыми трудностями, большинство из которых я мог решить с помощью Google и Stack Overflow, но этого я не могу.

Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: org.gradle.tooling.BuildException: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)

Также размещение моего приложения gradle

apply plugin: 'com.android.application'
   android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

defaultConfig {
    applicationId "com.intersoft.snappy"
    minSdkVersion 19
    targetSdkVersion 22
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
}
buildTypeMatching 'dev', 'debug'
buildTypeMatching 'qa', 'debug'
buildTypeMatching 'rc', 'release'
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] 
} }
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
maven { url "https://jitpack.io" }
maven { url 'https://dl.bintray.com/ashokslsk/CheckableView' }
maven { url "https://maven.google.com" }

}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.github.mrengineer13:snackbar:1.2.0'
implementation 'com.android.support:recyclerview-v7:26.0.1'
implementation 'com.android.support:cardview-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.android.support:percent:26.0.1'
implementation 'dev.dworks.libs:volleyplus:+'
implementation 'com.google.guava:guava:21.0'
implementation 'com.facebook.fresco:fresco:1.0.1'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.wdullaer:materialdatetimepicker:3.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.stfalcon:frescoimageviewer:0.4.0'
implementation 'com.github.piotrek1543:CustomSpinner:0.1'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.github.satyan:sugar:1.4'
implementation 'com.hedgehog.ratingbar:app:1.1.2'
implementation project(':sandriosCamera')
implementation('org.apache.httpcomponents:httpmime:4.2.6') {
    exclude module: 'httpclient'
}
implementation 'com.googlecode.json-simple:json-simple:1.1'
}

afterEvaluate {
tasks.matching {
    it.name.startsWith('dex')
}.each { dx ->
    if (dx.additionalParameters == null) {
        dx.additionalParameters = ['--multi-dex']
    } else {
        dx.additionalParameters += '--multi-dex'
    }
}
}
subprojects {
project.plugins.whenPluginAdded { plugin ->
    if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
        project.android.dexOptions.preDexLibraries = false
    } else if 
("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
        project.android.dexOptions.preDexLibraries = false
    }
}
}

buildscript {
repositories {
    mavenCentral()
}

dependencies {
    classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}
}

apply plugin: 'com.jakewharton.hugo'

также мой другой модуль gradle

apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

buildscript {
repositories {
    jcenter()
    jcenter()
    maven { url "https://maven.google.com" }
}
dependencies {
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
}

group = 'com.sandrios.android'
version = '1.0.8'

ext {
PUBLISH_GROUP_ID = 'com.sandrios.android'
PUBLISH_ARTIFACT_ID = 'sandriosCamera'
PUBLISH_VERSION = '1.0.8'
PUBLISH_CODE = 9
}

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"

defaultConfig {
    minSdkVersion 19
    targetSdkVersion 25
    versionCode PUBLISH_CODE
    versionName PUBLISH_VERSION
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
lintOptions {
    abortOnError false
}
}

task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}

task generateJavadocs(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath()
        .join(File.pathSeparator))
}

task generateJavadocsJar(type: Jar) {
from generateJavadocs.destinationDir
classifier 'javadoc'
}

generateJavadocsJar.dependsOn generateJavadocs

artifacts {
archives generateSourcesJar
archives generateJavadocsJar
}

install {
repositories.mavenInstaller {
    pom.project {
        name PUBLISH_GROUP_ID
        description 'Simple integration of universal camera in android for easy image and video capture.'
        url 'https://github.com/sandrios/sandriosCamera'
        inceptionYear '2016'

        packaging 'aar'
        version PUBLISH_VERSION

        scm {
            connection 'https://github.com/sandrios/sandriosCamera.git'
            url 'https://github.com/sandrios/sandriosCamera'

        }
        developers {
            developer {
                name 'arpitgandhi9'
            }
        }
    }
}
}

bintray {
Properties properties = new Properties()

properties.load(project.rootProject.file('local.properties').newDataInputStream())
user = properties.getProperty('bintray.user')
key = properties.getProperty('bintray.apikey')
configurations = ['archives']
pkg {
    repo = 'android'
    name = 'sandriosCamera'
    userOrg = 'sandriosstudios'
    desc = 'Android solution to simplify work with different camera apis.'
    licenses = ['MIT']
    labels = ['android', 'camera', 'photo', 'video']
    websiteUrl = 'https://github.com/sandrios/sandriosCamera'
    issueTrackerUrl = 'https://github.com/sandrios/sandriosCamera/issues'
    vcsUrl = 'https://github.com/sandrios/sandriosCamera.git'
    version {
        name = PUBLISH_VERSION
        vcsTag = PUBLISH_VERSION
        desc = 'Minor fixes.'
        released = new Date()
    }
}
}

repositories {
jcenter()
}

dependencies {
implementation 'com.android.support:support-v4:26.0.0'
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:recyclerview-v7:26.0.0'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.yalantis:ucrop:2.2.0'
implementation 'gun0912.ted:tedpermission:1.0.2'
}

а также уровень проекта gradle

// Top-level build file where you can add configuration options common to 
all sub-projects/modules.

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0-beta2'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

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

пожалуйста, помогите мне избавиться от этой ошибки.

4b9b3361

Ответ 1

Нашел свой ответ, для меня лично он использовал

implementation "com.google.guava:guava:23.0"

Вместо

implementation "com.google.guava:guava:23.0-android"

Ответ 2

Это важная часть:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Также вы забыли добавить репо для плагина:

buildscript {
    repositories {
        jcenter()
        google()
    }
}

Ответ 3

У меня были те же ошибки (SimException), с которыми вы столкнулись. У меня было 3 модуля в проекте чистой архитектуры Android:

  • данные (андроидная библиотека)
  • домен (простой Java-модуль)
  • презентация (приложение - все материалы для Android)

решение

перейдите к File/Project Structure...

убедитесь, что ваши модули имеют одинаковую совместимость с исходниками и мишенями (в этом случае 1,8)

Ответ 4

У меня была такая же проблема. Недавно я удалил папку кэша .gradle и переустановил Android Studio и SDK. В конце концов, когда пыталась git bisect проблема, она уходила. Я могу только догадываться, почему это произошло, но я подозреваю, что загрузка старых версий инструментов сборки и SDK, а также создание (и предположительно кэширование) версий нашего кода с помощью этих более старых инструментов заставили его построить таким образом, не вызывают проблем.

Это указывает на какую-то ошибку в том, что новые инструменты сборки (API 26?) строят исходный код, поэтому моя рекомендация, если вы видите эту проблему, а другие решения не работают, - это чтобы снизить целевую версию SDK до 25 или ниже, установите необходимые инструменты для сборки и попробуйте выполнить компиляцию кода с ними, прежде чем возвращаться к сборке инструментов 26 или выше.

Ответ 5

Я добавил библиотеку с compileOptions Java 1.8, а в моем основном проекте - нет. Исправлено добавление:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}