FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ‘:app:compile...

1.错误原因:

笔记: 在运行android的项目时报错: 咱就是说代码不知道检查多少遍了(^_^)!!!,反正代码可以肯定的是没错的,于是就去网上搜索啊

按照提示在build.gradle(Module.app)加了如下代码

android{

    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }
}

然后重新编译发现我的不行,(^_^)!! 一运行就是这样.此小项目就需要该配置但是我的不行,(不过有的人可以成功运行)

2.解决办法:

网上搜罗,磕磕绊绊,误打误撞,终于解决了!(不能成功运行的原因就是我的Compile Sdk Version 是32 所以不能编译成功)

        (1) 方法一: 降低你的版本即可,可以直接从build.gradle(Module:app)里直接修改,点击右上角Sync Now进行同步,30或者29都可以,改完后关闭重新打开

         (2) 方法二: 在 build.gradle(Module:app)文件里,点击右上角Open Project Structure 

                               

更改完之后关闭重新打开

3.结果

        成功了!!!

 

 

 

Executing tasks: [:app:assembleDebug] in project D:\Users\lenovo\AndroidStudioProjects\Pinduoduo WARNING: The specified Android SDK Build Tools version (27.0.0) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.2. Android SDK Build Tools 28.0.3 will be used. To suppress this warning, remove "buildToolsVersion '27.0.0'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools. > Task :app:preBuild UP-TO-DATE > Task :app:preDebugBuild UP-TO-DATE > Task :app:checkDebugManifest UP-TO-DATE > Task :app:generateDebugBuildConfig UP-TO-DATE > Task :app:javaPreCompileDebug UP-TO-DATE > Task :app:mainApkListPersistenceDebug UP-TO-DATE > Task :app:generateDebugResValues UP-TO-DATE > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE > Task :app:mergeDebugShaders UP-TO-DATE > Task :app:compileDebugShaders UP-TO-DATE > Task :app:generateDebugAssets UP-TO-DATE > Task :app:compileDebugRenderscript NO-SOURCE > Task :app:compileDebugAidl NO-SOURCE > Task :app:generateDebugResources UP-TO-DATE > Task :app:mergeDebugResources UP-TO-DATE > Task :app:processDebugManifest > Task :app:processDebugResources FAILED AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"D:\\Users\\lenovo\\AndroidStudioProjects\\Pinduoduo\\app\\src\\main\\res\\layout\\activity_main.xml","position":{"startLine":34}}],"original":"D:\\Users\\lenovo\\AndroidStudioProjects\\Pinduoduo\\app\\src\\main\\res\\layout\\activity_main.xml:35: AAPT: error: '#875ale' is incompatible with attribute textColor (attr) reference|color.\n ","tool":"AAPT"} FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > Android resource linking failed D:\Users\lenovo\AndroidStudioProjects\Pinduoduo\app\src\main\res\layout\activity_main.xml:35: AAPT: error: '#875ale' is incompatible with attribute textColor (attr) reference|color. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 3s 11 actionable tasks: 2 executed, 9 up-to-date
06-07
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值