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

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

错误信息

模块:应用程序build.gradle文件我添加了上次的依赖目标兼容性,但它根本不工作。 每当我在我的设备运行它显示上面的错误 – >

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

请告诉我如何解决它。

One Solution collect form web for “将字节码转换为dex在实际设备中运行时出错”

这个错误清楚地告诉你在库的子模块中将targetsource兼容性改为1.7 。 为什么不能改变呢?

我想这可能会让你改变这个:

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

对此:

 compileKotlin { kotlinOptions { jvmTarget = "1.7" } } compileTestKotlin { kotlinOptions { jvmTarget = "1.7" } } 
  • 如何在Enum常量中实现抽象函数
  • 从LinkedHashMap中提取映射值作为ArrayList
  • Android JUnit测试SQLiteOpenHelper
  • 由于重复,Kotlin gradle.build ZipException
  • Android上的Kotlin Closable和SQLiteDatabase
  • 类型参数在Kotlin中不被识别
  • kotlin android中的setOnLongClickListener
  • 如何使用Kotlin enum和Retrofit?
  • Beta由Crashlytics - 包似乎已损坏
  • 与新的类Kotlin recyclerView
  • Java完成非零退出值2 - Android Gradle
  • Kotlin language will be the best programming language for Android.