Android SDK Build-tools 22.0.1 inventing folders inside res in generated APK

Asked

Viewed 391 times

4

I’m using the Android Studio 1.2.1.1, with the Gradle 2.2.1, and this is an excerpt (the relevant part) of my resource folder structure:

res
 |- layout
 |- layout-v21
 |- values
 |- values-v11
 |- values-v13
 |- values-v14
 |- values-v21
 |- xml

When I Go the APK with the Android SDK Build-tools 20.0.0, this same structure is the one found inside the APK file (which can be checked by opening the APK file with various file compression programs such as the 7-zip).

However, when I switch to the Android SDK Build-tools 22.0.1, the folder structure within the APK looks like this one below:

res
 |- layout
 |- layout-v11
 |- layout-v21
 |- values
 |- values-v11
 |- values-v13
 |- values-v14
 |- values-v21
 |- xml
 |- xml-v14
 |- xml-v17

Detail for the folders layout-v11, xml-v14 and xml-v17 that are not part of my project.

This, in addition to impacting the final size of the APK file, leaves me worried. What am I doing wrong? Is there any new configuration in the version 22.0.1?

For now, I solved the "problem" just by staying with the version 20.0.0, but would like to know how to solve this, to migrate to the newer version, without folders and resources appearing in APK.

Updating

After much internet search (unsuccessful) and many tests, I believe I have discovered what makes the Android SDK Build-tools 22.0.1 "invent" such folders in APK.

I ran some initial tests on the folders layout and layout-v21. Among all XML files inside the folder layout, some of them have elements with the following attributes:

android:splitMotionEvents
android:nextFocusForward

Both attributes belong to API 11, and the minimum API supported by my project is API 10.

Thus, it seems, during the generation of the APK, the Android SDK Build-tools 22.0.1 kept a copy of my layouts removing attributes mentioned, and created a folder layout-v11 where he kept the layouts with the attributes, the way I created them.

This behavior is strange, because the IDE itself says it’s not wrong to keep new attributes in layouts that will be used with old Apis (she says, and I’ve tested it numerous times: devices with old Apis simply ignore these attributes silently).

I did not add this as an answer because I still need to perform further tests to confirm this theory.

  • I may be mistaken, but this happens as a kind of backup and compatibility, but it’s been a while since I work with Android (so much so that I used Eclipse at the time)

  • @And you know how to disable this in Android Studio?

  • 1

    I’m not sure, but I don’t think this is "disabled", I can’t say for sure, but until Sunday I install androidstudio and will test :)

  • @Guillhermenascimento reached some conclusion? :)

  • carlos my internet is not helping rs, I’m still downloading :( I thought my colleague had himself the androidstudio, but he only had the eclipse

1 answer

1

Some features of Material Design like the Material Theme and custom transitions activities are only available on Android 5.0 (API level 21) and higher. However, you can design your applications to make use of these features when running on devices that support material design and still be compatible with devices that run earlier versions of Android.

Folders as layout-v11, values-v11, xml-v14, etc. are created to provide compatibility of Material Design for older versions of Android.

Note that you can also create custom folders to make the application’s "visual" or "structure" different for each device.

(Source: Developer Material Compatibility)

  • Yes! These folders are normally created when creating a new project. My point is that I already have an existing project, and the folders pointed in question appear only within the generated APK (they don’t exist in the Android Studio tree or in my project folder) :/

  • @carlosrafaelgn I get it, but that’s right, to give compatibility APK if you are using Material Design you need to create these folders. I edited the answer, removed the initial part of the answer that confused a little :) - sorry

  • Interesting behavior! I say this because I don’t use Material Design or Material Theme in my app, and I don’t use none lib from those compat and support. Yet it creates the folders... and creates the folders for seemingly random versions (v11, v14 and v17) :( The most worrying thing is that the folder xml (to whom it generates the versions v14 and v17) even contains layout! :(

  • 1

    @carlosrafaelgn and this will ultimately hurt you in what? your apk will get heavier?

  • 1

    @carlosrafaelgn if the folders are there should be because Android Studio needs them.

  • @Paulohenriqueneryoliveira Actually, it is. It creates a copy of the layouts by removing some new API attributes from the files in the older API folders, attributes that would do no harm if they continued there, as I explained in the "Update" section of June 2015. Really solved using the build-tools 20.0.0. Since I didn’t do any more tests, I didn’t publish it as an answer, so I didn’t mark the question as closed :)

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.