(1) "Gradle project sync failed .Please fix your project and try again"
三种解决办法:
① File -> Invalidate caches/Restart...
关闭Android Studio,然后重命名或者删除用户目录下的.gradle文件夹
重启Android Studio下载Gradle
重新编译项目
②打开File下的Settings搜索gradle,将Offline work选上
③从其他项目中拷贝gradle和.gradle两个目录,覆盖本项目的这两个目录。
(2)"ADB not responding. If you'd liketo retry, then please manually kill "adb.exe" and ......"
出现这个错误一般是5037的端口号被占用,可以尝试以下方法:
win+ R打开运行,输入cmd打开命令提示符
输入命令 netstat -ano | findstr "5037" 查找占用5037端口号进程的PID,如下:
C:\Users\asus>netstat-ano | findstr "5037"
TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 964
TCP 127.0.0.1:5037 127.0.0.1:51336 TIME_WAIT 0
TCP 127.0.0.1:5037 127.0.0.1:51337 TIME_WAIT 0
此时占用端口的是PID为964的进程。
杀死进程有两种办法:
①askkill /pid 964 -f"
②下快捷键"Ctrl + Alt +Del"打开任务管理器,找到对应的PID号,点击结束进程
(3)com.android.dex.DexException: Multipledex files define(重复引用包)
将build.gradle中
dependencies {
compilefileTree(dir: 'libs', include: ['*.jar'])
testCompile'junit:junit:4.12'
compile'com.android.support:appcompat-v7:23.4.0'
}
改成:
dependencies {
providedfileTree(dir: 'libs', include: ['*.jar'])
testCompile'junit:junit:4.12'
compile'com.android.support:appcompat-v7:23.4.0'
}
(4)Could not findcom.android.support.constraint:constraint-layout:1.0.7-alpha3
Tools -----> Android ----->SDK Manager ----> 点击SDK Tools标签 ---->选择show pack details,找到support repository ----> constraintlayout for android下面可以看到现在你的系统中安装了constraint-layout:1.0.7-alpha3没有 ----> 选择你想安装的版本,点apply,会出现下载安装有界面。
(5)Error:Could notdownloadhamcrest-core.jar (org.hamcrest:hamcrest-core:1.3): No cached versionavailablefor offline mode
删掉或者注释build.gradle中的testCompile 'junit:junit:4.12' , 然后打开File--->Settings,在左上角的搜索栏中输入InstantRun,将右边的Enable Instant Run to hotswap code/resource changes ondeploy(default enabled)前面的对勾去掉。
(6)Error:Unable to tunnel throughproxy.Proxy returns "HTTP/1.1 400 Bad Request"
Settings ——> 选中Use local gradle distribution ——> 设置与studio版本匹配的gradle ——> OK
(7)http://schemas.android.com/apk/res/android URI is not registered
File ——> Settings ——> Plugin ——> 勾选AndroidSupport
(8)Error:(48, 0) Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.
task clean(type: Delete) {
delete rootProject.buildDir
}
Android Studio常见问题及解决办法
最新推荐文章于 2025-03-26 11:36:16 发布