Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: error: annotations are not supported in -source 1.3

I've tried to add some modules, and when i rebuild the project i got this error:

error: annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations) 

i'v deleted the modules, but the error is staying. tried clean and rebuild, didn't help.

i understood it something to do with the java maven, but i didn't understand how to solve it. Maybe someone here could help?

this is my Gradle:

buildscript {
ext.kotlin_version = '1.3.31'
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.2.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://maven.java.net/content/groups/public/"
    }

    maven { url 'https://jitpack.io' }

    maven { url "https://maven.google.com" }


  }
}

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






apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'


android {
   compileSdkVersion 28
   defaultConfig {
      applicationId "com.eldareini.kotlin.meet4match"
      minSdkVersion 21
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner 
  "android.support.test.runner.AndroidJUnitRunner"

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

packagingOptions {
    pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
compileOptions {
    sourceCompatibility = kotlin_version
    targetCompatibility = kotlin_version
}
   buildToolsVersion = '28.0.3'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.sun.mail:android-mail:1.6.0'
implementation 'com.sun.mail:android-activation:1.6.0'
implementation 'com.github.mac229.FragmentUtils:fragmentutils-kt:1.0.1'
implementation 'com.github.mac229.FragmentUtils:fragmentutils:1.0.1'
implementation 'com.sun.mail:android-mail:1.6.0'
implementation 'com.sun.mail:android-activation:1.6.0'
implementation 'org.webrtc:google-webrtc:1.0.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
like image 272
Eldar Avatar asked Jun 16 '19 17:06

Eldar


People also ask

What is the latest version of annotation in androidx?

androidx.annotation:annotation:1.3.0 is released. Version 1.3.0 contains these commits. Important changes since 1.2.0 @Discouraged annotation for marking APIs that cannot be reasonably deprecated but have significant negative performance impact and should not be called in normal production code

Are the annotations included by default in the support library?

The annotations are not included by default; they are shipped as a separate library. (The support library is now made up of a number of smaller libraries: v4-support, appcompat, gridlayout, mediarouter, and so on.) (If you're using the appcompat library, you already have access to the annotations, because appcompat itself depends on it.)

What's new in the Android support library?

The support library itself has also been annotated with these annotations, so as a user of the support library, Android Studio will already check your code and flag potential problems based on these annotations. As of version 22.2 of the support library, there are an additional 13 new annotations you can also use.

What is the purpose of resource annotations in Android?

Resources in Android are typically passed around as integers. That means code which expects a parameter to refer to a drawable can easily be passed a reference to a string; they are both of type int and the compiler is happy. The resource type annotations allow you to add some type checking on top of this.


1 Answers

You are using the Kotlin version of the library to specify the source/target compatibility of your build.

The problem is here:

compileOptions {
    sourceCompatibility = kotlin_version
    targetCompatibility = kotlin_version
}

kotlin_version is 1.3

Try the following:

compileOptions {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}
like image 109
Jared Burrows Avatar answered Nov 09 '22 08:11

Jared Burrows