0

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

未找到“应用程序”的变体。检查构建文件以确保至少存在一种变体。

已经尝试过 ,但没有帮助。我是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

在此处输入图像描述

4

1 回答 1

0

正如其他答案中所解释的,您要查看的是应用程序级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。

于 2021-05-25T21:32:37.023 回答