gpt4 book ai didi

android - 将 key 文件放入 APK

转载 作者:行者123 更新时间:2023-12-04 10:36:46 24 4
gpt4 key购买 nike

尝试使用 gradle 构建应用程序 apk 文件,任务 assemble .我的应用程序包含私钥文件,但出现错误:

E:\D\android\MQTT\app\src\main\res\raw\clientkey.pem: Error: The raw\\clientkey.pem file seems to be a private key file. Please make sure not to embed this in your APK file. [PackagedPrivateKey]

Explanation for issues of type "PackagedPrivateKey":
In general, you should not package private key files inside your app.

1 errors, 0 warnings

> Task :app:lintVitalRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Lint found fatal errors while assembling a release target.

To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
...

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s

我知道将 key 保存在 apk 中并不安全,但目前我想将其放在 apk 中。如何做到这一点?

最佳答案

可以按文件禁用此检查;模块 build.gradle :

lintOptions {
lintConfig file("../lint.xml")
}

根项目 lint.xml
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="PackagedPrivateKey">
<ignore path="src/main/res/raw/clientkey.pem"/>
</issue>
</lint>

关于android - 将 key 文件放入 APK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60141376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com