调用动态要求 --min-SDK-version >= 26



今天下载了Studio 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'

也是我的另一个模块毕业

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'
}

以及项目级的成绩

// 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"
}
}
}

请帮助我摆脱此错误

这是重要的部分:

您需要将其添加到该模块的build.gradle中,它不像应用程序模块那样添加。

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

您也忘了为插件添加存储库:

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

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

  • 数据(安卓库(
  • 域(纯Java模块(
  • 演示文稿(应用程序 - 所有安卓的东西(

溶液

导航到File/Project Structure...

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

我添加了一个带有compileOptions Java 1.8的库,而在我的主项目中没有。 固定添加:

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

找到我的答案,对我个人来说,它是使用

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

而不是

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

我遇到了同样的问题。我最近删除了我的.gradle缓存文件夹,并重新安装了Android Studio和SDK。最终,当试图git bisect问题时,它消失了。我只能推测为什么会发生这种情况,但我怀疑下载旧版本的构建工具和 SDK,并使用这些旧工具构建(并可能缓存(我们的代码版本会导致它以不会导致问题的方式构建。

这表明较新的(API 26?(构建工具正在构建源代码的方式存在某种错误,因此,如果您看到此问题并且其他解决方案不起作用,我的建议是将目标SDK版本降低到25或更低,安装必要的构建工具,并尝试使用这些工具编译代码, 在恢复到构建工具 26 或更高版本之前。

相关内容

最新更新