agamemnus / cordova-plugin-xapkreader

Easily access Google Play APK expansion file data.
32 stars 55 forks source link

AndroidX (fix for sudden build failure - AAPT error resource not found) #138

Open erobertson42 opened 4 years ago

erobertson42 commented 4 years ago

So today I go to build my app, and it fails for no apparent reason - nothing changed but some minor CSS. After a bunch of digging, it looks like on June 17, Google released a new major version (17.0.0) of the Play Services libraries which have breaking changes.

Unfortunately, this caused the xapkreader plugin to fail to build because it has its framework dependency defined too loosely, which causes it to always use the latest available version.

AAPT: error: resource android:attr/fontVariationSettings not found.
AAPT: error: resource android:attr/ttcIndex not found.

Fortunately, the fix is simply to update plugin.xml by replacing the line:

<framework src="com.google.android.gms:play-services-base:+" />

... with ...

<framework src="com.google.android.gms:play-services-base:16.+" />

The main issue is that with version 17 of Play Services, the Android Support libraries are being deprecated in favor of the Jetpack AndroidX libraries. So while the simple fix above works for now, it's more of a stop-gap. Eventually, all Cordova Android plugins using Google Play Services will need to migrate to AndroidX. Unfortunately, that's not something I had time to dive into at the moment, so I'll go with the easy fix for now. :)

(Unrelated to xapkreader, but relevant to the topic, all this also applies to Firebase.)