Android studio导入外部项目无法运行+报错 Cause: unable to find valid certification path to requested target

1 关于一些安卓源码在自己的AndroidStudio中无法运行的解决方法

1.前言
在安卓学习中,有时候会从GitHub上下载一些安卓编程源码,然而在使用Android Studio导入项目时发现根本不能运行,这时候就需要对源码进行一些修改。在此只需要修改三处即能让项目正常运行。
2.解决办法
从GitHub上下载的项目目录如下
在这里插入图片描述3.我们所需要修改的三个地方:
(1)build.gradle文件(此为项目根目录下的文件)
在这里插入图片描述将标红部分修改为你的AndroidStudio中的版本,如果不知道版本号,就可以新建一个项目,然后查看。下面两个地方同样的查看方式。
(2)app文件夹中的build.gradle。
在这里插入图片描述在这里插入图片描述如果新建的项目中没有buildToolsVersion版本号,可以file-project structure-Modules下面的app右侧查看Build Tools Version。
(3)gradle/wrapper/gradle-wrapper.properties文件
在这里插入图片描述
这时候项目应该就可以正常运行了。
番外:
(1)如果出现Error:Could not find com.android.tools.build:gradle:3.0.1.(亲测可用)。
在这里插入图片描述
附上参考文章:
(1)https://blog.csdn.net/baidu_37378518/article/details/78155736
(2)https://blog.csdn.net/a34927341/article/details/52949842
(3)Gradle下载地址:http://services.gradle.org/distributions/

2 Cause: unable to find valid certification path to requested target 报错

1、首先修改根目录下的build.gradle成如下格式

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
  repositories {
    maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
    maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.6.1'
 
    // 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/repositories/google' }
    maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
  }
}

2、然后点击sync project with gradle files,如下图所示
在这里插入图片描述
3、 如果再次报错请清理缓存并重启AS,方法如下图
在这里插入图片描述
4、(最重要的步骤)如果再次报错,请不厌其烦的且厚不要脸的多次点击这个小象(即重复第二步操作),正常情况下奇迹会发生的。(反正我是见证该奇迹了)
转自https://www.jb51.net/article/182527.htm

3 还是版本问题

在这里插入图片描述
在这里插入图片描述

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值