【问题标题】:Android studio error No variants found for 'app'Android工作室错误没有找到'app'的变体
【发布时间】:2021-05-04 20:27:21
【问题描述】:

我正在打开这个 webview 项目并在导入项目时立即遇到错误。

未找到“app”的变体。检查构建文件以确保至少存在一个变体。

已经尝试过this,但没有帮助。我是android新手,请帮忙。

以下是build.gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.41'
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

这是完整的项目https://github.com/mgks/Kotlin-SmartWebView

enter image description here

【问题讨论】:

    标签: android kotlin webview


    【解决方案1】:

    正如this other answer 中所述,您要查看的是应用程序级别的build.gradle 文件(您在此处拥有的是顶级build.gradle 文件)。获取compileSdkVersion并使用SDK Manager下载对应的Android SDK版本。

    build.gradle 文件示例

    
    android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.app-10.app"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    

    在上面的示例中,compileSdkVersion 是 29,因此要下载的 Android SDK 版本(使用 SDK Manager)将是 API 级别 29。

    【讨论】:

      猜你喜欢
      • 2023-03-20
      • 2016-10-26
      • 1970-01-01
      • 2015-05-25
      • 2018-02-20
      • 2016-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多