关于Android studio配置引起的报错:A problem was found with the configuration of task ‘:app: processDebugMain…

报错问题1
安装完Android studio之后,新建第一个helloworld项目,意外的收获一枚报错,如上图所示。

经过不断的重装以及降低版本均宣告失败以后,最后我还是选择求助于大佬帮忙解决。以下是解决的全部过程:

  • 首先,我更换了app包下的build.gradle文件内容
plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 22
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        flavorDimensions "versionCode"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    defaultConfig {
        manifestPlaceholders = [ activityLabel:"defaultName"]
    }
    productFlavors {
        free {
        }
        pro {
            manifestPlaceholders = [ activityLabel:"proName" ]
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

然后神奇的是,这个可爱的小东西换了一种报错方式(如下图) 结论是,还是版本的问题。

报错内容

  • 解决无果后,大佬建议再次修改app下的build.gradle。插入下面的代码于图中所示位置:
flavorDimensions "versionCode"

在这里插入图片描述

然后点右上角的Sync now 开始更新

  • 更新完毕后,这个小东西又开始出别的问题(心态已经可以开始裂了),如下所示。
    在这里插入图片描述
  • 最后(终于最后了),还是如下图降低了版本,然后BUILD SUCCESSFUL~
    降低版本
    成功运行!!
    撒花~~~

但愿在如此曲折的安卓开场之后,后面的路会稍微顺畅一点!

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值