Vis*_*shi 17 android warnings build build.gradle
我在 android studio 中创建了一个新项目并添加了所有依赖项。所有这些都是最新的。当我构建项目时,我收到了这些警告。应用程序中没有代码。这些在我添加依赖项后开始显示。
我应该就这样离开吗?
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding = true
}
}
dependencies {
def version_nav = "2.3.4"
def lifecycle_version = "2.3.0"
def version_retrofit_coroutines_adapter = "0.9.2"
def version_kotlin_coroutines = "1.3.9"
def version_moshi = "1.9.2"
def retrofit ="2.9.0"
def hilt_version = "2.31-alpha"
def hilt_viewmodels = "1.0.0-alpha03"
def fragment_ktx = "1.3.1"
def okhttp = "4.9.0"
def moshi_converter = "2.8.1"
def recycler_view_version = "1.2.0-beta02"
def timber_version = "4.7.1"
def java_poet_version = "1.13.0"
def coil_version = "1.1.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// Timber
implementation "com.jakewharton.timber:timber:$timber_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit"
implementation "com.squareup.retrofit2:converter-gson:$retrofit"
// Moshi
implementation "com.squareup.moshi:moshi:$version_moshi"
implementation "com.squareup.moshi:moshi-kotlin:$version_moshi"
implementation "com.squareup.retrofit2:converter-moshi:$moshi_converter"
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$version_nav"
implementation "androidx.navigation:navigation-ui-ktx:$version_nav"
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version_kotlin_coroutines"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version_kotlin_coroutines"
// Retrofit Coroutines Support
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$version_retrofit_coroutines_adapter"
//RecyclerView
implementation "androidx.recyclerview:recyclerview:$recycler_view_version"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
// Lifecycle only (without ViewModel or LiveData)
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
//OkHttp3
implementation"com.squareup.okhttp3:okhttp:$okhttp"
//Hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
//Hilt View models
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_viewmodels"
kapt "androidx.hilt:hilt-compiler:$hilt_viewmodels"
//Fragments
implementation "androidx.fragment:fragment-ktx:$fragment_ktx"
//Java Poet
kapt "com.squareup:javapoet:$java_poet_version"
//Coil
implementation "io.coil-kt:coil:$coil_version"
}
kapt {
correctErrorTypes true
}
Run Code Online (Sandbox Code Playgroud)
该应用程序运行时没有任何问题,但由于这是我第一次看到的警告。我在其他任何地方都找不到任何相关内容,想知道为什么会这样。
小智 25
发生这种情况是由于旧的 gradle 插件版本所致。
我确实将 SDK 版本更改为 31,但我的 gradle 插件是 4.2。所以我面临着同样的问题。
要解决此问题,只需转到项目级别的 build.gradle 并将 gradle 插件版本更新到最新版本,如下所示:
buildscript {
// ...
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
}
}
Run Code Online (Sandbox Code Playgroud)
在撰写本答案时,Gradle 7.0.2是最新版本。
小智 17
我正在使用 Android Studio Arctic Fox(2020.3.1,补丁),它指向buildToolsVersion "30.0.2"并得到相同的错误。我通过将 Android Gradle 插件版本从 更新为4.1.0来修复此问题7.0.2。

Ate*_*rus 16
将 Flutter 升级到版本 3.0后,我在VSCode构建Flutter应用程序时收到类似的错误消息。以下为我修复了它。
android:exported="true"或。您必须选择的内容以及有关“android:exported”的更多详细信息请参见此处android:exported 详细信息android:exported="false"activity'1.6.10'gradle 版本的“classpath”更改为'com.android.tools.build:gradle:7.1.2'https\://services.gradle.org/distributions/gradle-7.4-all.zipflutter clean删除旧的构建内容。完成此操作后,构建运行时不会出现任何错误或警告。
编辑:原始帖子适用于 Flutter 版本 2.10。我更新了 Flutter 3.0 版本的版本号
小智 11
我遇到了同样的问题,结果发现buildToolsVersion "30.0.3"使用的没有安装,所以我切换到安装的buildToolsVersion "29.0.3"(在我的情况下)并且警告消失了。