SendGrid for Android

Viewed 332

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 Answers

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.

Related