

Taras Leskiv
3 min read - Aug 20, 2020
How to force the Unreal Engine Android project to use AndroidX?
A quick Unreal Plugin Language tweak to enable AndroidX and Jetifier in Unreal Engine 4 Android builds so modern SDKs keep working.
Unreal Engine 4.25.3 still ships with the old Android support libraries. Modern SDKs like AdMob, Firebase, Facebook, and others now require AndroidX, so we needed a way to force Unreal's generated Gradle project to use it automatically.
Upgrading SDKs without AndroidX led to Google Play rejections (for example, the outdated Vungle mediation SDK warning), so we built the migration into our plugins.
Why do we need it?
Newer Android SDKs depend on AndroidX. Using legacy support libs meant shipping outdated dependencies and dealing with store rejections. We needed an automated fix that survived every Unreal build.
The approach
Unreal generates an intermediate Gradle project at Intermediate/Android/APK/Gradle. Instead of manually migrating it in Android Studio (it gets regenerated on each launch), we use Unreal Plugin Language (UPL) to:
- Add AndroidX flags to
gradle.propertiesbefore the build. - Rewrite Java imports that still point to old support libraries.
- Let Jetifier handle transitive dependencies that still reference support libs.
1) Enable AndroidX and Jetifier
Add this to your UPL XML so the generated gradle.properties gets the right flags:
1<gradleProperties>2 <insert>3 android.useAndroidX=true4 android.enableJetifier=true5 </insert>6</gradleProperties>
2) Rewrite Java imports
Use baseBuildGradleAdditions to run a pre-build script that walks Java files and swaps legacy support imports for AndroidX equivalents:
1<baseBuildGradleAdditions>2 <insert>3 afterEvaluate { project ->4 def replacements = [5 'android.support.v4.app.NotificationCompat' : 'androidx.core.app.NotificationCompat',6 'android.support.v4.content.ContextCompat' : 'androidx.core.content.ContextCompat',7 'android.support.v4.app.ActivityCompat' : 'androidx.core.app.ActivityCompat'8 ]910 def javaFiles = fileTree(projectDir) {11 include '**/*.java'12 }1314 javaFiles.each { file ->15 def text = file.getText('UTF-8')16 replacements.each { oldImport, newImport ->17 if (text.contains(oldImport)) {18 file.write(text.replace(oldImport, newImport), 'UTF-8')19 }20 }21 }22 }23 </insert>24</baseBuildGradleAdditions>
Adjust the imports map for any classes your plugin relies on. The key is running before compilation so Gradle sees AndroidX symbols.
3) Let Jetifier handle dependencies
With android.enableJetifier=true, Google's Jetifier rewrites third-party dependencies that still reference old support libs. Combined with the import rewrite, the project builds cleanly using AndroidX.
Result
The UPL changes survive every Unreal rebuild, enabling AndroidX automatically, keeping mediation SDKs current, and avoiding Play Store rejections without manual Android Studio steps.