Android studio导入报错

1.导入项目,一直报错,build多次,超时,远程仓库有的下载不下来,
感觉是build.gradle中jcenter()或maven()被墙了,但是我这翻墙build还是失败。

org.gradle.internal.resource.transport.http.HttpRequestException: Could not HEAD 'http://jcenter.bintray.com/net/sf/proguard/proguard-base/6.0.3/proguard-base-6.0.3.jar'.
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:96)
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performRawHead(HttpClientHelper.java:72)
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performHead(HttpClientHelper.java:76)
	at org.gradle.internal.resource.transport.http.HttpResourceAccessor.getMetaData(HttpResourceAccessor.java:65)
	at org.gradle.internal.resource.transfer.DefaultExternalResourceConnector.getMetaData(DefaultExternalResourceConnector.java:63)
	at org.gradle.internal.resource.transfer.AccessorBackedExternalResource.getMetaData(AccessorBackedExternalResource.java:201)
	at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator$1.call(BuildOperationFiringExternalResourceDecorator.java:61)
	at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator$1.call(BuildOperationFiringExternalResourceDecorator.java:58)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:350)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:340)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:120)
	at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator.getMetaData(BuildOperationFiringExternalResourceDecorator.java:58)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor$1.create(DefaultCacheAwareExternalResourceAccessor.java:102)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor$1.create(DefaultCacheAwareExternalResourceAccessor.java:82)
	at org.gradle.cache.internal.ProducerGuard$AdaptiveProducerGuard.guardByKey(ProducerGuard.java:97)
	at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.getResource(DefaultCacheAwareExternalResourceAccessor.java:82)
	at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadByCoords(DefaultExternalResourceArtifactResolver.java:138)
	at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadStaticResource(DefaultExternalResourceArtifactResolver.java:98)
	at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.resolveArtifact(DefaultExternalResourceArtifactResolver.java:67)
	at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveArtifact(ExternalResourceResolver.java:432)
	at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.resolveArtifact(CachingModuleComponentRepository.java:427)
	at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveArtifact(ErrorHandlingModuleComponentRepository.java:181)
	at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainArtifactResolver.resolveArtifact(RepositoryChainArtifactResolver.java:80)
	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DefaultArtifactSet$LazyArtifactSource.create(DefaultArtifactSet.java:170)
	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DefaultArtifactSet$LazyArtifactSource.create(DefaultArtifactSet.java:157)
	at org.gradle.api.internal.artifacts.DefaultResolvedArtifact.getFile(DefaultResolvedArtifact.java:135)
	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ArtifactBackedResolvedVariant$DownloadArtifactFile.run(ArtifactBackedResolvedVariant.java:148)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.access$900(DefaultBuildOperationExecutor.java:63)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$ParentPreservingQueueWorker.execute(DefaultBuildOperationExecutor.java:378)
	at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.runOperation(DefaultBuildOperationQueue.java:230)
	at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.access$600(DefaultBuildOperationQueue.java:172)
	at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable$1.call(DefaultBuildOperationQueue.java:209)
	at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable$1.call(DefaultBuildOperationQueue.java:203)
	at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
	at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.runBatch(DefaultBuildOperationQueue.java:202)
	at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.run(DefaultBuildOperationQueue.java:177)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloudfront.net/13.32.163.156, d29vzk4ow07wi7.cloudfront.net/13.32.163.143, d29vzk4ow07wi7.cloudfront.net/13.32.163.165, d29vzk4ow07wi7.cloudfront.net/13.32.163.161] failed: Read timed out
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:148)
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:126)
	at org.gradle.internal.resource.transport.http.HttpClientHelper.executeGetOrHead(HttpClientHelper.java:103)
	at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:94)
	... 45 more
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
	at java.net.SocketInputStream.read(SocketInputStream.java:171)
	at java.net.SocketInputStream.read(SocketInputStream.java:141)
	at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
	at sun.security.ssl.InputRecord.read(InputRecord.java:503)
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
	... 57 more


网上找了几个方法,
使用开源中国的maven库:
阿里云的:http://maven.aliyun.com/nexus/content/groups/public/
参考这个,修改了下build.gradle,问题解决了



buildscript {
    
    repositories {
		maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

allprojects {
    repositories {
      	maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

2.Android studio 3.2设置字体大小
菜单"File"-“Setting…”
在左边的菜单中选择"Editor"-“Font”

3.Android studio 设置注释模板
在这里插入图片描述


/**
 * @author DaQiang
 * @Date $date$ $time$
 * @Desc
 */

### 回答1: 您好,可能是由于以下原因导致Android Studio导入图片报错: 1. 图片文件格式不正确,Android Studio只支持png、jpg、jpeg、gif等格式的图片。 2. 图片文件路径不正确,确保图片文件路径正确且文件存在。 3. 图片文件命名不规范,建议使用小写字母、数字、下划线、短横线等字符命名。 4. 图片文件大小超过了Android Studio的限制,建议将图片压缩至合适的大小。 如果以上方法都无法解决问题,建议您检查Android Studio的版本是否过低或者重新安装Android Studio。 ### 回答2: 在Android Studio导入图片时,有时会出现错误。常见的错误消息有:“无法加载位图”、“未找到某些文件”和“无法解析文件路径”等。这些错误通常是由以下原因导致的: 1. 文件路径错误:在导入图片时,需要确保文件路径正确。如果文件路径无效或不正确,就会导致加载位图失败、文件丢失或解析失败等错误。 2. 文件格式不支持:Android Studio支持多种文件格式,如JPEG、PNG等。如果导入的文件格式不受支持,那么也会导致出现错误。 3. 图片过大:如果图片尺寸过大,那么Android Studio可能无法加载它。可以尝试缩小图片的尺寸、分辨率或压缩图像文件以减小文件大小。 如果您遇到了以上情况,可以尝试以下解决方案: 1. 检查文件路径:确保文件路径正确,并且所需文件存在于正确的位置。检查文件名、目录和后缀名是否正确。 2. 检查文件格式:确保导入的文件格式受支持。可以查看Android Studio文档以获取支持的文件格式列表。 3. 缩小图片:可以通过缩小图片的尺寸、分辨率或压缩文件来减小文件大小。可以使用在线工具或专门的工具来完成这个过程。 总之,在导入图片时,需要注意文件路径、格式和大小。如果仍然无法解决问题,可以尝试重新安装Android Studio或升级到最新版本,并确保该版本支持所需的库和文件格式。此外,使用调试工具可以帮助您查找和解决问题。 ### 回答3: Android Studio 是一款非常流行的 Android 应用开发工具,它为开发者提供了丰富的功能和工具,能够帮助我们更加高效地开发出优秀的 Android 应用。在 Android 应用开发中,经常会用到图片,如何将图片导入Android Studio 中是我们需要掌握的一项基本技能。 在 Android Studio导入图片的操作非常简单,只需要将图片文件复制到项目中的 drawable 目录中即可。但有时候在导入图片的时候,会出现一些错误提示,下面是一些常见的错误提示及解决方案: 1. “Error:Execution squence failed for task ':app:mergeDebugResources'. ” 这个错误提示通常是由于图片文件名包含非法字符所导致的。因此,我们需要将包含非法字符的图片文件名进行修改,如将文件名中的中文、特殊符号等替换为英文。 2. “Error:Execution squence failed for task ':app:mergeDebugResources'. Resolving drawable resource failed.” 这个错误提示通常是由于图片文件格式不正确所导致的。Android Studio 支持导入多种格式的图片文件,如 PNG、JPG 等,但不支持 SVG 格式。因此,我们需要将 SVG 格式的图片文件转换为 PNG 或 JPG 等支持的格式。 3. “Error:Execution squence failed for task ':app:mergeDebugResources'. Duplicate resource.” 这个错误提示通常是由于导入的图片已经存在于项目中的 drawable 目录中,但是文件名不同导致的冲突。因此,我们需要检查项目中是否已经存在相同的图片文件,如有需要删除冗余的图片文件。 总之,在导入图片的过程中,我们需要注意图片文件名、格式和重复等方面的问题,避免出现错误提示。如果遇到无法解决的问题,可以通过查看日志或者重启 Android Studio 等方式来进行排查和解决。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值