Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android library vector converted to png and Kotlin files obfuscated by default

I just create a new android project with Android Studio(AS). I add a library module with a vector drawable and a Kotlin file with comments. I run assemble release and it generates an aar file.

I open this aar release file with AS decompiler and I see the vector file is converted to png for different drawables and the Kotlin file is obfuscated saying compiled code.

The original xml vector file can be found only in directory drawable-anydpi-v24

How can I disable vector to png and file obfuscation for my library module?

I have default build.gradle: minifyEnabled false

(I am already aware of org.jetbrains.dokka so please don't say just use it)

like image 266
Ultimo_m Avatar asked Feb 09 '21 11:02

Ultimo_m


1 Answers

Thanks to @Gustavo comment in my question I started investigating even more regarding the issue with generated png files.

I have the min sdk 21, I tried also 22 and it had the same result. Then after some playing with vectors I find out that what caused my issue was the property android:fillType="evenOdd"

I tested with this property and without it and I had these 2 results:

Source 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>

I had these 2 results for the aar build:

without the fill type value without the fill type value

with fill type value with fill type value

After that I find this question in stackoverflow

After I set the minSdk to 24, the png files are not generated anymore.

I can not work with minSdk so low currently but at least I know what is causing it.

like image 150
Ultimo_m Avatar answered Sep 28 '22 00:09

Ultimo_m