Execution failed for task ‘:app:configureCMakeDebug 错误踩坑记录

在使用AndroidStudio时发生如下错误。由于错误已经解决无法复现,找了一下别人的错误日志贴上

Execution failed for task ':app:configureCMakeDebug[arm64-v8a]'.
> [CXX1429] error when building with cmake using C:\Users\Dell\AndroidStudioProjects\MyApplication2\app\src\main\cpp\CMakeLists.txt: -- Android: Targeting API '31' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
  -- Android: Selected unified Clang toolchain
  -- The C compiler identification is unknown
  -- The CXX compiler identification is Clang 12.0.8
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: D:/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
  -- Check for working C compiler: D:/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - broken
  -- Configuring incomplete, errors occurred!

解决办法:在微软官网下载vc_redist.x64 这么一个VC++ 的库装上就好了。

解决思路参考:出现问题搜了全网各种找都找不到正常解决办法,有提到跳过编译检查的,有提到指定这个库哪个库的都不好使。我也新建了native module的项目,发现一运行不止v8a,什么x86啊v7a全都报错。最终代码指向了C:\Users\{}\AppData\Local\Android\Sdk\cmake\3.22.1\bin下的cmake.exe文件,抱着试一试的想法,我双击这个文件,跳出来个窗口MSVCP140D.dll缺失

那还能怎么办呢... 装运行库就解决了

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
这个错误通常是由于dex方法数超出限制引起的。你可以尝试以下方法解决: 1. 在appbuild.gradle文件中添加下面的代码: ```groovy android { defaultConfig { ... multiDexEnabled true } ... } dependencies { implementation 'com.android.support:multidex:1.0.3' } ``` 然后在你的Application类中添加下面的代码: ```java public class MyApplication extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } ... } ``` 2. 如果你使用了很多第三方库,可以尝试使用ProGuard来优化代码。在appbuild.gradle文件中添加下面的代码: ```groovy android { ... buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } ``` 然后在app的根目录下创建一个proguard-rules.pro文件,添加下面的代码: ``` -dontwarn okio.** -dontwarn javax.annotation.** -dontwarn com.squareup.okhttp.** -dontwarn retrofit2.Platform$Java8 -dontwarn retrofit2.Platform$Java8$.* -dontwarn retrofit2.Platform$Java9 -dontwarn retrofit2.Platform$Java9$.* -keep class com.google.gson.** { *; } -keep class org.apache.commons.io.** { *; } -keep class retrofit2.** { *; } -keepattributes Signature -keepattributes Exceptions -keepattributes InnerClasses ``` 注意:ProGuard可能会导致某些库出现问题,因此需要进行适当的测试和调整。 3. 如果以上方法都无法解决问题,可以尝试升级Gradle版本或者在项目中使用AndroidX。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值