Android Studio的几个Error与解决方案:“NDK not configured”;“Received close_notify during handshake”

Android Studio的几个Error与解决方案

  • NDK not configured. Download it with SDK manager.
    • 问题
    • 解决问题
  • Received close_notify during handshake.
    • 问题
    • 解决问题
  • 参考

NDK not configured. Download it with SDK manager.

问题

新安装的Android Studio报出以下错误:
Android Studio的几个Error与解决方案:“NDK not configured”;“Received close_notify during handshake”_第1张图片
其实,已经安装了NDK。但我还是点击Update试了试。然后就遇到了另一个问题:==Could not find method ndkVersion() for arguments on object of type com.android.build.==如下图:

解决问题

通过点击提示Open File发现文件的android标签的最下面有这么一行:

ndkVersion '21.2.6472646'

这行就是问题所在了,但去掉后还会出现最开始的NSK not configured的错误,套娃出现。这是因为项目中没有配置NDK的路径,编译时找不到了,所以打开local.properties文件,发现果然没有ndk的配置,加上本机的NDK路径:

ndk.dir=D\:\\AndroidSDK\\ndk\\16.1.4479499
sdk.dir=D\:\\AndroidSDK

再次编译,SUCCESSFUL!

Received close_notify during handshake.

问题

Android Studio报出以下错误:Received close_notify during handshake.
问题存在原因:这是Android编译错误,jcenter里面的东西下载不了引起的。

解决问题

在项目的build.gradle文件中将jcenter()换成阿里的源,具体示例代码如下。

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

修改之后再重新Sync Project即可。
整体代码如下。

buildscript {
    
    repositories {
        google()
        //jcenter()
        maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

参考

  1. https://blog.csdn.net/u012558210/article/details/106427634/
  2. https://blog.csdn.net/lxy1740/article/details/104606385/
  3. https://blog.csdn.net/qq_33618456/article/details/75808153

你可能感兴趣的:(Android,Studio)