• Android Studio运行kotlin项目,一直Read timed out


    Android Studio运行kotlin项目,一直Read timed out

    下载别人的Kotlin项目,导入as后,运行app一直失败,提示Read timed out,有2种解决办法

    第一种方式:gradle.properties

    修改kotlin项目种的gradle.properties文件

    systemProp.http.keepAlive=true
    systemProp.http.keepAliveDuration=600000
    
    • 1
    • 2

    第二种方式:使用aliyun maven(gradle7.0+)

    修改settings.gradle文件

    pluginManagement {
        repositories {
            gradlePluginPortal()
            google()
            mavenCentral()
        }
    }
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            maven {
                allowInsecureProtocol = true
                url 'http://maven.aliyun.com/nexus/content/groups/public/'
            }
            maven {
                allowInsecureProtocol = true
                url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
            }
            maven {
                allowInsecureProtocol = true
                url 'http://maven.aliyun.com/nexus/content/repositories/google'
            }
            maven {
                allowInsecureProtocol = true
                url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin'
            }
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
    }
    rootProject.name = "Shlla"
    include ':app'
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33

    修改项目目录中的build.gradle文件

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            maven {
                allowInsecureProtocol = true
                url 'http://maven.aliyun.com/nexus/content/groups/public/'
            }
            google()
            mavenCentral()
        }
        dependencies {
            // 这里指定的是grade的版本,与你自己grade版本对上就可以了
            // 太无语了,其实咱们就根据下面plugins中的版本一样 就可以了
            // 不用跟自己的grade保持一致,要低一点,也没关系,反正我是比自己的grade低,下面有图,咱们可以改成跟自己的grade一致,试试看
            classpath 'com.android.tools.build:gradle:7.3.1'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    plugins {
        id 'com.android.application' version '7.3.1' apply false
        id 'com.android.library' version '7.3.1' apply false
        id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
    }
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    依赖还是在app目录下的build.gradle中增加与修改。

    参考

    2022 最新 Android studio添加阿里云Aliyun Maven仓库

    在 build.gradle.kts 添加 maven 仓库

    Android Studio : Read timed out和connect timed out的解决方法

  • 相关阅读:
    Consul安装使用
    Java如何创建支付接口
    使用JSON字符串生成Java实体类
    面试:Service及生命周期相关问题
    前端开发面试题—CSS清除浮动的方法
    汽车冲压车间的RFID技术设计解决方案
    关于错误码
    SpringMVC_基本使用
    408计算机网络知识点简记 (背诵用
    怎样优雅地增删查改(五):按组织架构查询
  • 原文地址:https://blog.csdn.net/fromVillageCoolBoy/article/details/133848481