首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >invokedynamic需求--min版本>= 26

invokedynamic需求--min版本>= 26
EN

Stack Overflow用户
提问于 2017-08-24 12:50:37
回答 5查看 29.6K关注 0票数 44

今天下载了Studio3.0Beta2.0版本,之后尝试在其中打开一个现有的项目,并遇到了一些困难,其中大部分我可以借助Google和Stack溢出来解决,但这次我无法解决。

代码语言:javascript
运行
复制
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)

也发了我的应用程序

代码语言:javascript
运行
复制
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'

还有我的另一个模块

代码语言:javascript
运行
复制
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'
}

以及项目级别等级

代码语言:javascript
运行
复制
// 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"
    }
}
}

请帮助我消除这个错误。

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2017-08-24 19:18:10

找到了我的答案,对我个人来说

代码语言:javascript
运行
复制
implementation "com.google.guava:guava:23.0"

而不是

代码语言:javascript
运行
复制
implementation "com.google.guava:guava:23.0-android"
票数 12
EN

Stack Overflow用户

发布于 2017-08-24 13:15:34

它是重要的部分:

您需要将其添加到该模块的build.gradle中,而不像app模块那样添加。

代码语言:javascript
运行
复制
android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

另外,您忘了为插件添加repo:

代码语言:javascript
运行
复制
buildscript {
    repositories {
        jcenter()
        google()
    }
}
票数 83
EN

Stack Overflow用户

发布于 2017-09-08 09:04:13

我遇到了与您相同的错误(SimException)。我在android清洁架构项目中有3个模块:

  • 数据(android库)
  • 域(普通java模块)
  • 演示文稿(应用程序-所有android的东西)

解决方案

导航到File/Project Structure...

确保模块具有相同的源和目标兼容性(本例中为1.8)

票数 21
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45862140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档