簡體   English   中英

Android Studio:Dex無法解析版本52字節代碼

[英]Android studio: Dex cannot parse version 52 byte code

每當我嘗試編譯時,我都會收到以下錯誤-

錯誤:將字節碼轉換為dex時出錯:原因:Dex無法解析版本52字節碼。 這是由使用Java 8或更高版本編譯的庫依賴關系引起的。 如果您在庫子模塊中使用“ java” gradle插件,請向該子模塊的build.gradle文件中添加targetCompatibility ='1.7'sourceCompatibility ='1.7'。

我的build.gradle文件如下-

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
    applicationId "com.example.sbcappium"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
packagingOptions {
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/notice'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license'
    exclude 'META-INF/license.txt'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
 compile fileTree(include: ['*.jar'], dir: 'libs')
apply plugin: 'android'
targetCompatibility = '1.7'
sourceCompatibility = '1.7'

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'

})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile group: 'net.time4j', name: 'time4j-android', version: '3.24-2016i'
testCompile 'junit:junit:4.12'
compile files('libs/cglib-nodep-3.2.4.jar')


compile files('libs/commons-exec-1.3.jar')
compile files('libs/commons-io-2.5.jar')
compile files('libs/commons-lang3-3.5.jar')
compile files('libs/commons-logging-1.2.jar')

compile files('libs/gson-2.8.0.jar')
compile files('libs/guava-21.0.jar')
compile files('libs/hamcrest-core-1.3.jar')


compile files('libs/htmlunit-driver-2.26.jar')

compile files('libs/httpcore-4.4.6.jar')
compile files('libs/httpmime-4.5.3.jar')
compile files('libs/java-client-5.0.0-BETA8.jar')

compile files('libs/jetty-io-9.4.1.v20170120.jar')
compile files('libs/jetty-util-9.4.1.v20170120.jar')
compile files('libs/jna-4.1.0.jar')

compile files('libs/junit-4.12.jar')

compile files('libs/phantomjsdriver-1.4.0.jar')
compile files('libs/sac-1.3.jar')
compile files('libs/selenium-server-standalone-3.4.0.jar')
compile files('libs/serializer-2.7.2.jar')
compile files('libs/websocket-api-9.4.3.v20170317.jar')
compile files('libs/websocket-client-9.4.3.v20170317.jar')
compile files('libs/websocket-common-9.4.3.v20170317.jar')
compile 'com.android.support:support-annotations:25.3.1'}

我已經嘗試了以下鏈接中提供的所有解決方案,但對我沒有任何幫助-

  1. Android:Dex無法解析版本52字節代碼
  2. Andrioid Studio-將字節碼轉換為dex時出錯,原因:Dex無法解析52版字節碼

我的build.gradle文件怎么了? 請記住,我已根據以上兩個鏈接中提供的解決方案對gradle文件進行了所有可能的更改。

請將此代碼添加到您的build.gradle

  compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

希望你的問題得到解決

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM