如何解决JDK错误?

时间:2016-05-14 12:14:04

标签: android android-studio java-8 openjdk

我已下载新的Android Studio 2.1并将openJDK升级到版本8.

enter image description here

但我有这个问题:

enter image description here

我做错了什么,我该怎么做?

谢谢!

添加gradl

buildscript {
repositories {
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
}
}

apply plugin: 'com.android.application'

repositories {
jcenter()
}

dependencies {
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:cardview-v7:23.3.0'
compile files('libs/svgandroid.jar')
compile 'com.android.support:design:23.3.0'
compile 'com.github.bumptech.glide:glide:3.5.2'

compile files('libs/guava-16.0.1.jar')
compile 'com.google.code.gson:gson:2.6.1'
}

// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
    'main',     // main sample code; look here for the interesting stuff.
    'common',   // components that are reused by multiple samples
    'template'] // boilerplate code that is generated by the sample template process

android {

buildTypes {
    release {
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
                'proguard-rules.pro'
    }
}

compileSdkVersion 23
buildToolsVersion "23.0.2"

repositories {
    mavenCentral()
}

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 21
    multiDexEnabled true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

sourceSets {
    main {
        dirs.each { dir ->
            java.srcDirs "src/${dir}/java"
            res.srcDirs "src/${dir}/res"
        }
    }
    androidTest.setRoot('tests')
    androidTest.java.srcDirs = ['tests/src']
}
}

1 个答案:

答案 0 :(得分:0)

请参阅文档:http://tools.android.com/tech-docs/configuration/osx-jdk

它涉及设置$STUDIO_JDK环境变量。