【发布时间】:2020-10-24 09:29:03
【问题描述】:
将 Gradle 依赖项添加到我的 Android 项目后。因此,当我尝试构建/运行我的项目时,我收到此错误 Unsupported class file major version 59 下面我添加了 Gradle 文件应用级别和项目级别。我试着搜索一遍,但找不到任何相关的答案。我也在 Github SendGrid 问题中提出了同样的问题,但还没有得到任何回应。
//App-level Gradle I have added this
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.app.hiforce"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
applicationIdSuffix = '.dev'
debuggable = true
buildConfigField('String', 'BaseUrl', DevBaseUrl)
manifestPlaceholders = [appLabel: "DEV-HiForce"]
}
release {
minifyEnabled false
buildConfigField('String', 'BaseUrl', ReleaseUrl)
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//Networking
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.0.1'
implementation 'com.squareup.okhttp3:okhttp:4.0.1'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.6.0'
implementation 'com.google.firebase:firebase-config:19.2.0'
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation 'com.google.firebase:firebase-analytics:17.6.0'
// (Recommended) Add the Google Analytics & Crashlytics dependencies.
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.sendgrid:sendgrid-java:4.6.6'
}
apply plugin: 'com.google.gms.google-services'
// Apply the Crashlytics Gradle plugin
apply plugin: 'com.google.firebase.crashlytics'
//Proj Level gradle i added this
buildscript {
repositories {
google()
jcenter()
// Add Google's Maven repository.
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【问题讨论】: