gpt4 book ai didi

android - 在真实设备中运行时将字节码转换为 dex 时出错

转载 作者:行者123 更新时间:2023-11-30 00:23:46 27 4
gpt4 key购买 nike

我更新了 kolin 版本 1.1.4-2 然后我开始在真实设备上运行我的项目但是它显示了这个错误 ->

Error message

Module:app build.gradle 文件 我上次在依赖项中添加了 targetCompatibility,但它根本不起作用。每当我在我的设备上运行时,它都会显示上述错误->

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.company.projectname"
minSdkVersion 17
targetSdkVersion 26
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}

项目build.gradle文件->

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

buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

apply plugin: 'kotlin'

allprojects {
repositories {
jcenter()
}
}

repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

请告诉我如何解决。

最佳答案

该错误清楚地告诉您将库的子模块中的 targetsource 兼容性更改为 1.7。为什么不能改变它?

我想它可能要求你改变这个:

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

为此:

compileKotlin {
kotlinOptions {
jvmTarget = "1.7"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.7"
}
}

关于android - 在真实设备中运行时将字节码转换为 dex 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45792199/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com