Android studio:Dex无法解析版本52字节的代码

时间:2017-06-02 20:31:40

标签: android android-studio build.gradle

每当我尝试编译时都会出现以下错误 -

  

错误:将字节码转换为dex时出错:       原因:Dex无法解析版本52字节的代码。       这是由使用Java 8或更高版本编译的库依赖项引起的。       如果你在库子模块中使用'java'gradle插件添加       targetCompatibility ='1.7'       sourceCompatibility ='1.7'       到该子模块的build.gradle文件。

我的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 cannot parse version 52 byte code
  2. Andrioid Studio - Error converting bytecode to dex, Cause: Dex cannot parse version 52 byte code
  3. 我的build.gradle文件有什么问题?请记住,我已根据上述两个链接中提供的解决方案对gradle文件进行了所有可能的更改。

1 个答案:

答案 0 :(得分:0)

请将此代码添加到build.gradle

+--------+---------+-------+
|  make  |  model  | r_yr  |
+--------+---------+-------+
| toyota | corolla |  1999 |
| toyota |  camry  |  2002 |
| toyota |  qualis |  2004 |
| toyota |  rav4   |  2006 |
+--------+---------+-------+

我希望你的问题得到解决