Error: Default interface methods are only supported starting with Android N (--min-api 24)

這是在 Android Studio 中套用了 androidx.core 之後出現的問題,build project 出現以下錯誤:

Error: Default interface methods are only supported starting with Android N (--min-api 24): android.view.MenuItem androidx.core.internal.view.SupportMenuItem.setContentDescription(java.lang.CharSequence)

解決方法有 2 種:
1. 在 /app/build.gradle 修改 minSdkVersion 為 24
android {  
...
defaultConfig {
...
minSdkVersion 24
...
}
...
}

 

2.在 /app/build.gradle 加入以下內容
android {  
...
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
...
}

 

Orignal From: Error: Default interface methods are only supported starting with Android N (--min-api 24)

0 意見:

張貼留言

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews