解决-Gradle: build failed to resolve aar library dependency

本文介绍了解决在Android项目中引入AAR包时遇到的依赖找不到的问题,并提供了具体的配置步骤。

很多SDK都会以aar形式提供给我们。aar包会放在libs下面,然后在build.gradle文件里面加上下面这条语句将aar包导入到项目中。

    $ implementation(name: 'aar包的名字', ext: 'aar')

这个时候直接编译,可能会报错

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not find :StarwayRobotAbility_v1.1.1:.

解决办法:
在build.gradle的android{}下面,加上下面这段代码,重新编译,应该就可以了。

    repositories {
        flatDir {
            dirs 'libs'
        }
    }
Warning: Flutter support for your project's Android Gradle Plugin version (Android Gradle Plugin version 8.1.0) will soon be dropped. Please upgrade your Android Gradle Plugin version to a version of at least Android Gradle Plugin version 8.3.0 soon. Alternatively, use the flag "--android-skip-build-dependency-validation" to bypass this check. Potential fix: Your project's AGP version is typically defined in the plugins block of the `settings.gradle` file (F:\projects\flutter\hbw_edu_app\android/settings.gradle), by a plugin with the id of com.android.application. If you don't see a plugins block, your project was likely created with an older template version. In this case it is most likely defined in the top-level build.gradle file (F:\projects\flutter\hbw_edu_app\android/build.gradle) by the following line in the dependencies block of the buildscript: "classpath 'com.android.tools.build:gradle:<version>'". 2 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:checkDebugAarMetadata'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform compressor-3.0.1.aar (id.zelory:compressor:3.0.1) to match attributes {artifactType=android-aar-metadata, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Could not download compressor-3.0.1.aar (id.zelory:compressor:3.0.1) > Could not get resource 'https://repo.maven.apache.org/maven2/id/zelory/compressor/3.0.1/compressor-3.0.1.aar'. > Could not HEAD 'https://repo.maven.apache.org/maven2/id/zelory/compressor/3.0.1/compressor-3.0.1.aar'. > Got socket exception during request. It might be caused by SSL misconfiguration > Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: Connection refused: getsockopt > Failed to transform fijkplayer-full-0.7.16.aar (com.befovy.fijkplayer:fijk
最新发布
08-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值