设为首页 加入收藏

TOP

安卓工程错误1
2023-07-23 13:31:59 】 浏览:89
Tags:安卓工 程错误

错误1

  • 错误信息
15:43	Gradle sync failed: Could not find com.android.tools.build:gradle:7.0.2.
			Searched in the following locations:
			- https://jcenter.bintray.com/com/android/tools/build/gradle/7.0.2/gradle-7.0.2.pom
			If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
			Required by:
			project :
			Add google Maven repository and sync project
			Open File (847 ms)
  • 解决

    bulid.gradle(项目根目录)文件的相应地方中添加google(),然后同步

错误2

  • 错误信息

    15:21 Project AndroidSerialPort is using the following JDK location when running Gradle:
    C:/Users/XXXX/.jdks/corretto-1.8.0_322
    Using different JDK locations on different processes might cause Gradle to
    spawn multiple daemons, for example, by executing Gradle tasks from a terminal
    while using Android Studio.
    More info...
    Select a JDK
    Do not show this warning again

  • 问题分析

    如果使用守护进程特性会有一个问题,就是可能会出现多个守护进程的场景,这是因为守护进程可能在某些方面无法满足请求构建环境。比如如果守护进程运行在Java 8运行时,但是请求的环境调用Java 10,那么守护进程是不兼容的,必须启动另一个。此外,Java运行时的某些属性在JVM启动后无法更改。这也可能导致出现多个守护进程。

    为了避免出现这种情况,一个最好的解决方式时我们每次使用gradle进行项目构建时,尽量使用相同的JDK配置。

  • 解决办法

    1. 打开项目结构设置窗口,点击Gradle Settings

      image-20220329155621548

    2. 选择与其他正常的工程运行的JDK版本路径一致的选项

      image-20220329170034730

    3. 同步一下

? 该问题参考了这里

错误3

  • 错误信息

    Gradle sync failed: Could not find method compile() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. (17 s 734 ms)

  • 问题分析

    Gradle版本不兼容

  • 解决办法

    将build.gradle里的compile(低)替换成implementation(高),如下:

    修改前

image-20220329155742562

? 修改后

image-20220329170019987

同步

错误4

  • 错误信息

    Lint infrastructure error
    
  • 问题分析

    收到了同事给的源码包,在打包APK时出现错误,但是我的其他工程是可以正常打包的,怀疑是Gradle相关配置问题。

  • 解决办法

    使用Ctrl+Alt+Shift+s打开项目结构设置

    image-20220401171649632

    然后点击同步,重新打包,就好啦~

    image-20220401171752991

错误5

  • 错误信息

    An exception occurred applying plugin request [id: 'com.android.application']
    > Failed to apply plugin 'com.android.internal.application'.
       > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
         You can try some of the following options:
           - changing the IDE settings.
           - changing the JAVA_HOME environment variable.
           - changing `org.gradle.java.home` in `gradle.properties`.
    
    * 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.
    
  • 解决办法

    1. 更改编译版本
    2. 更新JDK版本
      File->Project Structure->Gradle Settings,选择合适的jdk,如下11 version 2.或者升级android studio 到最新版本,ok
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇AI赋能音乐创作,人人都是音视频.. 下一篇android studio 升级 Dolphin | 2..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目