日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

【错误记录】Android 编译时技术版本警告 ( 注解处理器与主应用支持的 Java 版本不匹配 )

發(fā)布時間:2025/6/17 Android 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【错误记录】Android 编译时技术版本警告 ( 注解处理器与主应用支持的 Java 版本不匹配 ) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

  • 一、報錯信息
  • 二、問題分析
  • 三、解決方案





一、報錯信息



在使用 Android 編譯時技術(shù) , 涉及 編譯時注解 , 注解處理器 ;

開發(fā)注解處理器后 , 編譯報如下警告 ;

該警告不會影響編譯 , 也不會中斷編譯的進(jìn)行 , 編譯依然能成功 ;

警告: 來自注釋處理程序 'org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor' 的受支持 source 版本 'RELEASE_7' 低于 -source '1.8': SupportedAnnotationTypes : kim.hsl.router_annotation.Route 1 個警告





二、問題分析



在 Android 主應(yīng)用的 build.gradle 構(gòu)建腳本中 , 支持的 Java 版本是 1.8 ;

android {compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8} }

在 編譯時注解 依賴庫 中的 build.gradle 構(gòu)建腳本如下 :

plugins {id 'java-library' }java {sourceCompatibility = JavaVersion.VERSION_1_7targetCompatibility = JavaVersion.VERSION_1_7 }

在注解處理器依賴庫 中的 build.gradle 構(gòu)建腳本如下 :

plugins {id 'java-library' }java {sourceCompatibility = JavaVersion.VERSION_1_7targetCompatibility = JavaVersion.VERSION_1_7 }dependencies {implementation fileTree(dir: 'libs', include: ['*.jar'])implementation project(path: ':router-annotation')annotationProcessor 'com.google.auto.service:auto-service:1.0-rc4'compileOnly 'com.google.auto.service:auto-service:1.0-rc4' }

注解處理器上使用 @SupportedSourceVersion 注解設(shè)置的支持的 Java 版本號也是 1.7 ;

// 自動注冊注解處理器 @AutoService(Processor.class) // 支持的注解類型 @SupportedAnnotationTypes({"kim.hsl.router_annotation.Route"}) // 支持的 Java 版本 @SupportedSourceVersion(SourceVersion.RELEASE_7) public class RouterProcessor extends AbstractProcessor { }



三、解決方案



將上述的 Java 版本號都設(shè)置為 1.8 ;

編譯時注解 依賴庫 的 build.gradle :

plugins {id 'java-library' }java {sourceCompatibility = JavaVersion.VERSION_1_8targetCompatibility = JavaVersion.VERSION_1_8 }

注解處理器 依賴庫 的 build.gradle :

plugins {id 'java-library' }java {sourceCompatibility = JavaVersion.VERSION_1_8targetCompatibility = JavaVersion.VERSION_1_8 }dependencies {implementation fileTree(dir: 'libs', include: ['*.jar'])implementation project(path: ':router-annotation')annotationProcessor 'com.google.auto.service:auto-service:1.0-rc4'compileOnly 'com.google.auto.service:auto-service:1.0-rc4' }

注解處理器 支持的 Java 版本號 : @SupportedSourceVersion(SourceVersion.RELEASE_8) 支持到 1.8 ;

// 自動注冊注解處理器 @AutoService(Processor.class) // 支持的注解類型 @SupportedAnnotationTypes({"kim.hsl.router_annotation.Route"}) // 支持的 Java 版本 @SupportedSourceVersion(SourceVersion.RELEASE_8) public class RouterProcessor extends AbstractProcessor { }

修改后 , 編譯時不再報上述警告 ;

總結(jié)

以上是生活随笔為你收集整理的【错误记录】Android 编译时技术版本警告 ( 注解处理器与主应用支持的 Java 版本不匹配 )的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。