android 允许私钥文件

fdbelqdn  于 2023-11-15  发布在  Android
关注(0)|答案(1)|浏览(190)

尝试使用Android Studio构建发布APK文件。关于现有私钥文件出现错误。是的,我已经添加了私钥文件,但我在当前版本中对此没有问题。如何允许在应用程序发布版本中包含私钥文件。如果我构建为Android,它不会抱怨这一点。
错误:

Lint found fatal errors while assembling a release target.

Fix the issues identified by lint, or create a baseline to see only new errors.
To create a baseline, run `gradlew updateLintBaseline` after adding the following to the module's build.gradle file:

android {
lint {
baseline = file("lint-baseline.xml")
}
}

For more details, see https://developer.android.com/studio/write/lint#snapshot

C:\projects\xxx\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.

   https://goo.gle/PackagedPrivateKey

1 errors, 0 warnings

字符串

qfe3c7zg

qfe3c7zg1#

我假设你知道hardcoded secrets can easily be exposed by reverse-engineering your app。所以当你像这样发布你的应用程序时,你的私钥将不再是私有的。

免责声明:对于常规用例,下面的解决方案并不适用,请使用Android Keystore来存储密钥。

如果您想忽略此警告,请尝试将以下内容添加到模块的build.gradle文件中:

android {
    ...
    lint {
        // Turns off checks for the issue IDs you specify.
        disable += "PackagedPrivateKey"
    }
}

字符串
有关更多linting配置选项,请参阅官方文档。

相关问题