Ult*_*o_m 5 android android-library kotlin
我只是用 Android Studio(AS) 创建了一个新的 android 项目。我添加了一个library module
带有矢量可绘制对象和一个带有注释的 Kotlin 文件。我运行 assemble release 并生成一个aar
文件。
我用 AS 反编译器打开这个 aar 发布文件,我看到矢量文件被转换为 png 以用于不同的可绘制对象,并且 Kotlin 文件被混淆了compiled code
。
原始xml矢量文件只能在目录中找到 drawable-anydpi-v24
如何禁用vector to png
和file obfuscation
用于我的库模块?
我有默认的 build.gradle: minifyEnabled false
(我已经知道org.jetbrains.dokka
所以请不要说只是使用它)
感谢@Gustavo 在我的问题中的评论,我开始调查更多有关生成的 png 文件的问题。
我有最小的 sdk 21,我也尝试了 22,结果相同。然后在玩了一些向量之后,我发现导致我的问题的是属性android:fillType="evenOdd"
我测试了这个属性和没有它的情况,得到了以下 2 个结果:
源 XML:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="80dp"
android:height="228dp"
android:alpha="0.81"
android:viewportWidth="99"
android:viewportHeight="284">
<path
android:fillAlpha="0.9"
android:fillColor="#33B8E3"
android:strokeLineJoin="round"
android:strokeLineCap="round"
android:strokeColor="#000"
android:strokeAlpha="0.9"
android:strokeWidth="1"
android:fillType="evenOdd" // removing this line
android:pathData="M49.5 112.842c25.366 0 48.654-27.702 48.654-57.745C98.154 25.054 76.371 0.7 49.5 0.7 22.63 0.7 0.846 25.054 0.846 55.097s23.287 57.745 48.654 57.745z" />
</vector>
Run Code Online (Sandbox Code Playgroud)
我的 aar 构建有以下 2 个结果:
当我设置minSdk
为24后,就不再生成png文件了。
我目前无法使用如此低的 minSdk,但至少我知道是什么原因造成的。