将插件添加到gradle

时间:2016-01-28 01:53:24

标签: java android gradle android-gradle build.gradle

当我为插件Permissions Dispatcher(https://github.com/hotchemi/PermissionsDispatcher)添加依赖项和类路径时,应用程序停止运行,给我这个错误消息

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.UnsupportedClassVersionError: permissions/dispatcher/RuntimePermissions : Unsupported major.minor version 52.0

Project Gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

buildscript {
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

模块Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "me.paxana.alerta"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.parse.bolts:bolts-android:1.3.0'
    compile 'com.parse:parse-android:1.12.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:support-annotations:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.nanohttpd:nanohttpd-webserver:2.1.1'
    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:3.0.0@aar'){
        transitive=true}
}

apply plugin: 'android-apt'

dependencies {
    compile 'com.github.hotchemi:permissionsdispatcher:2.0.4'
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.0.4'
}

1 个答案:

答案 0 :(得分:8)

该错误消息表示您正在执行使用Java的更高版本编译的代码,而不是执行JVM的代码。我认为版本52对应于Java 1.8。因此插件可能已经用1.8编译,而你的Gradle环境正在使用1.7或更早的JVM执行插件。

要解决此问题,请尝试以下操作:

  1. 在您的系统上安装Java 1.8 JDK。 (JRE可能就足够了)
  2. 将您的JAVA_HOME环境变量设置为指向此1.8 JDK。 Gradle将使用这个JDK,一切都应该很好。
相关问题