【发布时间】:2019-03-24 18:07:09
【问题描述】:
我在 android 上使用 signalr,添加了 official microsoft website 的依赖项后
compile 'com.microsoft.signalr:signalr:1.0.0'
我遇到了这个错误。
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
Gradle 同步成功。但构建失败。
请注意,我已经在 app.gradle 文件中添加了这些行,但没有成功。
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
这是我的 gradle 文件。
android {
compileSdkVersion 27
buildToolsVersion "28.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.adnanshaukat.myapplication"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*. jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
repositories {
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
compile "com.android.support:appcompat-v7:27.0.1"
compile "com.android.support:design:27.0.1"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.android.support:support-v4:27.0.1'
compile 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
compile 'com.jaredrummler:material-spinner:1.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.microsoft.signalr:signalr:1.0.0'
testCompile 'junit:junit:4.12'
}
模块 gradle 文件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// 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"
}
maven{
url 'https://jitpack.io'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
请帮助我已经尝试了 3 天但没有成功,将非常感谢 :-)
【问题讨论】: