android studio 4.1* PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExc

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

安装下面博客导入key  (仓库服务  这个网址)

关于gradle Cause: unable to find valid certification path to requested target错误解决方法   

仓库服务  这个网址内容加入加入 google 、jcenter

导入网站证书

keytool.exe  -importcert   -file D:\Users\Desktop\cert.cer  -keystore   "%JAVA_HOME%/jre/lib/security/cacerts"  -trustcacerts

buildscript {
    repositories {
        //google()
        //jcenter()
        google { url 'https://maven.aliyun.com/repository/google' }
        jcenter { url 'https://maven.aliyun.com/repository/jcenter' }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.0"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
       //google()
        //jcenter()
        google { url 'https://maven.aliyun.com/repository/google' }
        jcenter { url 'https://maven.aliyun.com/repository/jcenter' }
    }
}

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

Q:

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

找到自己 sdk 的目录位置,默认在 %AppData%\Local\Android\Sdk\Win + R 快捷键打开启动,输入 %AppData% 即可快速进入;
然后进入目录, build-tools\31.0.0,将 d8.bat 文件名改成 dx.bat;
然后继续找到 build-tools\31.0.0\lib 目录,将 d8.jar 改成 dx.jar 即可

Q:

The minCompileSdk (32) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-31).
Dependency: androidx.appcompat:appcompat-resources:1.5.0.
AAR metadata file: D:\Users\**\.gradle\caches\transforms-2\files-2.1\d4f92dafedf13532cae26856a5476ff6\jetified-appcompat-resources-1.5.0\META-INF\com\android\build\gradle\aar-metadata.properties.

build.gradle 文件

dependencies {

    implementation 'androidx.appcompat:appcompat:1.5.0'

androidx.appcompat:appcompat:1.4.1. 依赖库必须以 android-31 进行编译 ,  ‘androidx.appcompat:appcompat:1.0.0’ 依赖 android-28

将 androidx.appcompat:appcompat:1.5.0  改为  androidx.appcompat:appcompat:1.4.1 就可以了

Q:

Execution failed for task ':app:installDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl934948546.tmp/base.apk (at Binary XML file line #21): com.example.tracepro.MainActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.TracePro">
    <activity
        android:exported="true"

AndroidManifest.xml 里面添加 android:exported="true"

可能 gradle.properties文件

android.injected.testOnly=false

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException是Java中的一个错误,表示构建PKIX路径失败,无法找到有效的证书路径。这个错误通常发生在使用SSL连接时,由于Java不信任SSL证书导致的。 解决这个问题的方法有多种,其中一种是手动导入证书到本地的信任库。这种方法比较复杂,需要按照一定的步骤进行操作。另一种方法是信任SSL证书,可以通过以下步骤解决该问题: 1. 创建一个TrustManager,用于信任所有的SSL证书。可以使用X509TrustManager接口的实现类,如下所示: ```java import javax.net.ssl.X509TrustManager; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; public class TrustAllManager implements X509TrustManager { @Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } } ``` 2. 在使用SSL连接之前,将TrustManager设置为信任所有SSL证书。可以使用以下代码片段实现: ```java import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; // 创建SSL上下文 SSLContext sslContext = SSLContext.getInstance("TLS"); // 创建TrustManager数组,只包含一个TrustAllManager TrustManager[] trustManagers = {new TrustAllManager()}; // 初始化SSL上下文 sslContext.init(null, trustManagers, null); // 设置默认的SSLSocketFactory和HostnameVerifier HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true); ``` 通过以上步骤,你可以解决PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException错误。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值