安卓工作室 : No build variant found error

标签 android android-studio build android-gradle-plugin variant

我是 android 开发的新手,我在网上购买的一个项目上从头开始开发,按照文档,我遇到了一个错误,说 未找到“应用程序”的变体。检查构建文件以确保至少存在一种变体。
这是 build.gradle 代码

apply plugin: 'com.android.application'

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"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Third Party Libraries
//Glide library for image fetching from the web
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
//Material library for styling blocks
implementation 'com.google.android.material:material:1.0.0'
// Google Gson
implementation 'com.google.code.gson:gson:2.8.5'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
// Android-SpinKit
implementation 'com.github.ybq:Android-SpinKit:1.4.0'

implementation files('libs/YouTubeAndroidPlayerApi.jar')

// gotev/android-upload-service
implementation "net.gotev:uploadservice:3.5.2"

//A fast circular ImageView perfect for profile images
implementation 'de.hdodenhof:circleimageview:3.0.1'

implementation 'org.apache.commons:commons-io:1.3.2'

}

最佳答案

我刚刚解决了同样的问题:
工具 -> SDK 管理器
验证 的 SDK 平台包安卓 10.0 (具有 API 级别 29 的那个,就像您在 gradle 文件中定义的那样)被选中。
如果没有,请检查并应用更改。接受许可条款,安装软件包,然后 文件 -> 使用 Gradle 文件同步项目 (或再次打开项目)

关于安卓工作室 : No build variant found error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64366729/

相关文章:

java - 函数和可运行对象同时工作(如何?)(Android、Java)

java - Android Proguard 问题 - 仍然得到 "java.io.IOException: Can' t 进程类...“跳过混淆时出错

android-studio - gradle 是否使用 javavm 以外的 cacerts 文件?

android - 如何在 Ubuntu 中使用终端关闭 Android Studio

visual-studio - 当前选择的 "Solution Configuration"选项存储在 VS 2010 或 2012 中的什么位置?

android - 如何检查客户端是否连接到 XMPP 服务器

Android 直接链接到默认浏览器

android - Gradle 错误 - 在 APK AndroidManifest.xml 中复制了重复文件

如果目标位置不存在文件,Ant 任务将复制该文件

build - Intellij IDEA 项目中的自定义构建步骤