How to Add a Whale of Plugins to Your Android App


How to Add a Whale of Plugins to Your Android App

Is there a limit on how complex an android application can be? Most often, as a response, you can hear the opinion that such a restriction is the limitation of google play to the size of the added apk.

However, Multi-Programming Solutions has many popular applications, especially games, which have long overstepped this barrier and make no problems whatsoever. The point is that most of the space is occupied by resources (raster graphics, video and music), which are not necessary to be placed directly in the installation file (they can be placed in extension files or stored on their own servers, downloading as needed). Also if you want to have Log in function with Google, notifications and purchases, you should consider that you will meet the limitation in any way.

Can you imagine an Android game made in Unity that uses more than 64K Java methods? If your game exceeds the limit of 64K methods on a DEX file, you will have to poke around in your native plugins and / or build process. This post is an attempt to show different ways to solve the problem.

Understand your plugins

The most likely way to exceed this limit in Unity is to use native plugins. Native Android plugins are required in almost all Unity games. Unfortunately, some plugins are quite large. For example, Google Play Game Services itself contains almost 25K methods. This is a significant chunk of 64K that you are limited to.

Android Unity plugins usually consist of Unity C# code and native Android code and resources. Native code and resources are packaged either as an Android library project (Library Project), or as an Android Archive resource (AAR) in the Assets / Plugins / Android / directory. Project libraries are the old way to transfer components to the Android system, and AAR is a newer one. You will encounter plugins using both methods.

Classes in both project libraries and AAR exist in JAR files, which are simple zip files from compiled Java class files. The AAR file is also a simple zip of various Android resources. Some of them will become libs / *. Jar (also known as Java class archives). Library projects are simple directory structures, and the JAR, again, will be in libs / *. Jar.

Facebook Plugin Implementation For Unity

Approaches of minimizing the number of methods

All the developers split up into two camps: those who still work with traditional approach and those who use new Unity features and mostly save their time. First, let’s take a look at the usual approaches of avoiding limitations.


The way to reduce the number of Java methods contained in the game’s APK using the standard Unity build system is to delete or modify the JAR files included with the native Android plugins. An alternative way is to export the Unity project as an Android project, in which more powerful technologies can be applied.

Try each of the following techniques in turn:

  • Remove all plugins that are not used by the game

Google has broken Play Services into a set of modules. Use only those that you really need.

Use the Jar Jar Links tool with the zap rule to remove unnecessary classes from JAR files of plugins.

  • Export the project as an Android project to apply ProGuard or MultiDex

ProGuard is a tool used to obfuscate and remove unused classes and methods. MultiDex is a technology that allows you to use multiple DEX files in your APK, thus removing the limit of 64K methods in the game. Unity does not directly support these technologies, but you can use them by exporting a project as an Android project.

If nothing else helps, ProGuard can help lower the maximum limit. If this fails, use MultiDex. MultiDex has another limitation – it works only in API Level 14 (4.0) and higher. It is natively supported in Android (5.0) and higher. For versions 4.X you need to use support libraries. In addition, MultiDex has a list of known limitations.

If you need ProGuard or MultiDex, the first step is to export the Unity project as an Android project. If your project is complex enough, this in itself can be a daunting task. Most likely, it will also mean the unavailability of Unity Cloud Build.

However, with the right process, it may look like exporting to Xcode for iOS. After export, you need to set up an Android Studio or Gradle project, but this will be a one-time task. Re-exporting the project does not require new configuration of the Android assembly configuration.

The good side of this approach is that after setting up an Android Studio project, you can re-export a Unity project to the same directory. In this case, in general, an update of the Android Studio project is not required.

The bad side of this method is that the Android project will be associated with the files of the Android Studio project. Configuring dependencies will be challenging.


Gradle is an Android build system which makes a number of build processes automatic. This feature implies that numerous basic mistakes are less inclined to happen. Most strikingly in Unity, it decreases the methods reference, included in DEX (Dalvik Executable configuration) documents, implying that you are more averse to go over DEX limit issues. However, because of the distinctions between Gradle and the default Unity Android build system, some current tasks might be difficult to change over toGradle.

You can either build the output (APK) utilizing the Gradle construct system in Unity, or fare the Gradle task and assemble it in an outside apparatus (for example, Android Studio).

The Gradle feature gives you extra option to export your Unity project into Android Studio one if the Export Project option is checked. This option must be checked when Gradle is selected. Gradle option is generally helpful for the Android platform only. It can configure such issues as:

  • DEPS
  • SIGN

Another pro of Gradle is that it enables you to indicate your own gradle file to construct your Unity Project. Simply name the gradle file “mainTemplate.gradle” and place it in the <ProjectName>AssetsPluginsAndroid directory.

Beforehand, to utilize gradle file in your project, you should trade the Unity Project as Android Project then utilize an outsider programming like Android Studio or Eclipse to add gradle backing to your application. But now it is made that simpler. With upgrading Unity to version 5.5, you can now use Gradle to build for Android. Gradle is not as strict about errors compared with the existing Unity Android build system, meaning that some existing projects may be hard to convert to Gradle.

You would now be able to do that without sending out the project at all. It will save your time while building a mobile app and give you an opportunity to add as many apks as you need.

How to Make Money with a Unity 3D Game


Building a complex Android app is a project which needs a professional view and a pack of experience. There were the best approaches to reduce the APK and, fortunately, now you have a better knowledge how to solve the most common Android problem. Multi-Programming Solutions deals with such issues daily and open to new ideas and tasks.

Contact us to get the consultation.

For ClientsMarch 14, 2019
Have a project in mind?
We are ready to do it!
Do you like this article?Please rate
5 stars
Why Does Localization Matter for eCommerce and How to Make It Right?
Initially, retail was the driving force behind the market. In the light of recent events, its transformation into e-commerce has accelerated. So, the brands have the opportunity to develop faster and easier while passing up all sorts of bureaucratic costs. Many brands began to compete for the worldwide customers' attention. That means the time when the business localization carried a different context has passed [...]
2020 Quarantine ECommerce Statistics and What It Says About the Future of Print on Demand
In 2020, when the pandemic was little known, many marketing reports predicted a shift in purchasing power towards e-commerce. Everyone expected international trading to prosper and become omnichannel, and social media transformed into active marketplaces (especially Instagram). For print on demand companies, it seemed that the significant changes would take a long time. Back in 2019, there was growing skepticism towards Gen Z brands. Moreover, the boomer generation's practicality excluded online shopping and focused on traveling to the store. The increased focus on personalization and sustainability only gained momentum. How it was in 2020 and what changes 2021 promises - that's what we'll discuss below [...]
How to Implement PWA in an e-Commerce Store?
Throughout the entire history of humankind, our adaptivity has been the major propellant of progress that allowed our society to develop at a rapid pace and eventually reach the stage of digital civilization. In the business world of the early third millennium, adaptivity largely spells the ability of entrepreneurs to take high-tech innovations in their stride and adjust their marketing strategies accordingly. The prize in this resilience test is the realization of big-time aspirations via expanding the clientele and catering to the needs (and even pandering to the whims) of the ever greater number of customers [...]
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More