2024.2.2

  • 电脑意外断电重启后所有项目编译报错 Illegal Capacity: -1
    通过查看C:\Users\Administrator\AppData\Local\Google\AndroidStudio2024.2\log\idea.log
    搜索Caused by
Caused by: org.gradle.api.GradleException: Could not read cache value from 'C:\Users\Administrator\.gradle\daemon\8.10.2\registry.bin'.
Caused by: java.lang.IllegalArgumentException: Illegal Capacity: -1

最终,将C:\Users\Administrator\.gradle\daemon\8.10.2\registry.bin.lock文件删除重新打开项目就好了。

其它版本

1.Android Studio中的Gradle面板没有Task任务列表

https://blog.csdn.net/qq_41680720/article/details/118025933

1)点击Android Studio–>Preference–>选择Experimental(实验性选项)–>在Gradle一栏中取消勾选"Do not build Gradle task list during Gradle sync"

2)点击File–>Sync Project with Gradle Files即可

2.Warning: debug info can be unavailable. Please close other application using ADB解决办法

开关一下开发者选项,或者重启手机。

3.Android studio 设置代理后清除不了

通过ide里的http proxy是无法删除的
https://www.jianshu.com/p/3f9381ef71e4

项目结构切换成Android
打开Gradle Scripts栏
发现有两个gradle.properties
找到.gradle下的gradle.properties文件清除。

4.导入别人的项目报错:can not found build tools xxx

5.你的主机中软件中止了一个已建立的连接

一般是电脑没有联网或者网络不好,可能你做了一些需要网络的操作:如切换BuildVariants.

6.This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled.

可能原因1:down下来的as项目里缺少gradle.properties文件.

7.“***" IS NOT TRANSLATED IN ……..

https://blog.csdn.net/admans/article/details/84998741
https://blog.csdn.net/u011050129/article/details/103523031

app 的build.gradle文件中,android 标签下使用
lintOptions { disable 'MissingTranslation', 'ExtraTranslation' }

8.AAPT: error: failed to read PNG signature: file does not start with PNG signature.

在app/build.gradle文件中加以下代码后,重构项目

aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
9.Could not initialize class org.codehaus.groovy.reflection.ReflectionCache

https://www.jianshu.com/p/9b58d2fd9423
安装的android studio过新,但是使用的gradle版本太旧。
一般更新至新建项目默认的gradle版本即可。

10.恢复英文语言

https://blog.csdn.net/leelfcn/article/details/123792512

11.Minimum supported Gradle version is 6.1.1. Current version is 4.8.

这里的4.8指的是grale/wrapper/gradle-wrapper.properties中的distributionUrl指定的gradle版本,与工程根目录下的build.gradle中的classpath版本不一致。根据版本关系对应表 (官网:https://developer.android.com/studio/releases/gradle-plugin#updating-plugin)对上即可。

12.Unable to load class 'javax.xml.bind.annotation.XmlSchema'.

gradle-wrapper中gradle版本和项目级build.gradle中gradle插件版本不匹配

13.gradle下载慢

配置aliyun镜像https://www.codeleading.com/article/45626249099/

    maven{ url 'https://maven.aliyun.com/repository/jcenter'}
    maven { url 'https://maven.aliyun.com/repository/google' }    
    maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
    maven { url 'https://maven.aliyun.com/repository/public' }

如果依然慢,开启VPN,从google官网https://services.gradle.org/distributions/ 下载gradle包,然后按照
https://xmanyou.com/manual-install-gradle-for-android-studio/教程将-all.zip的gradle包放到C:\Users\admin\.gradle\wrapper\dists\gradle-5.4.1-all\3221gyojl5jsh0helicew7rwx目录下。

14.android studio gradle task wrapper not found in project

直接打开了module,而没有打开项目。

15.
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-8.11.1-bin.zip'.
Reason: java.net.SocketTimeoutException: Connect timed out

解法办法,见https://blog.csdn.net/weixin_46078387/article/details/143787889

android/gradle/gradle.wrapper.properties下面的源换成国内的阿里云或是腾讯云

腾讯云
https://mirrors.cloud.tencent.com/gradle/
阿里云
https://mirrors.aliyun.com/macports/distfiles/gradle/

Kotlin相关问题

pluginManagement {
    repositories {
        maven { setUrl("https://maven.aliyun.com/repository/public/") }
        maven { setUrl("https://maven.aliyun.com/repository/spring/")}
        maven { setUrl("https://maven.aliyun.com/repository/google/")}
        maven { setUrl("https://maven.aliyun.com/repository/spring-plugin/")}
        maven { setUrl("https://maven.aliyun.com/repository/grails-core/")}
        maven { setUrl("https://maven.aliyun.com/repository/apache-snapshots/")}
        maven { setUrl("https://maven.aliyun.com/repository/central") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
        google {
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.name = "HappyBirthday"
include(":app")
  • Duplicate class android.support.v4.app.INotificationSideChannel found in modules

https://juejin.cn/post/7149796214874046472

如果出现了这个错误,确保以下两行代码同时出现在gradle.properties文件中

android.useAndroidX=true
android.enableJetifier=true

0 条评论

发表回复

您的电子邮箱地址不会被公开。