Android Studio常见问题及解决办法

本文针对Android开发过程中常见的错误提供了解决方案,包括Gradle项目同步失败、ADB无响应、Dex异常等,并提供了详细的步骤指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

(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
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值