英文:
SendGrid for Android
问题
在将Gradle依赖项添加到我的Android项目后,当我尝试构建/运行项目时,我会收到以下错误消息:不支持的类文件主版本59。以下是我添加的应用级和项目级Gradle文件。我尝试了各种搜索,但未找到相关答案。我还在Github的SendGrid Issues中提出了相同的问题,但尚未收到任何回复。
// App-level Gradle中我添加了以下内容
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'
// 网络
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'
// (推荐)添加Google Analytics和Crashlytics依赖项。
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'
// 应用Crashlytics Gradle插件
apply plugin: 'com.google.firebase.crashlytics'
// 项目级Gradle中我添加了以下内容
buildscript {
repositories {
google()
jcenter()
// 添加Google的Maven仓库。
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'
// 注意:不要将应用程序的依赖项放在这里;它们应位于各个模块的build.gradle文件中
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
(以上内容为翻译后的代码部分,不包含问题的回答。)
英文:
After adding Gradle dependencies to my Android Project. So when I try to build/run my project I get this error Unsupported class file major version 59
Below I have added both the Gradle files App-level as well as the Project level. I tried searching all the over but couldn't find any related answer. I have also put the same in Github SendGrid Issues but didn't got any response yet.
//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
}
答案1
得分: 2
集成Sendgrid的Java库到Android并不是一件直接的事情...
实际上,我已经使用Sendgrid的最新API为Android构建了一个Sendgrid库。
https://github.com/Jakebreen/android-sendgrid
implementation 'uk.co.jakebreen:android-sendgrid:1.2.3'
我在维护这个库,所以如果你有任何问题,请在GitHub页面上创建一个问题记录。
英文:
Integrating Sendgrids java library into android isn't straight forward...
I've actually built a Sendgrid library for Android using Sendgrid's latest API.
https://github.com/Jakebreen/android-sendgrid
implementation 'uk.co.jakebreen:android-sendgrid:1.2.3'
I maintain it so if you have any questions log an issue on the github page.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论