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.


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.

TechnologiesMarch 14, 2019
Have a project in mind?
We are ready to do it!
Do you like this article?Please rate
5 stars
Materials Which Print-On-Demand Business Works With
More and more entrepreneurs have opted for inkjet printing, a greener and more efficient alternative to the classic one with a master image carrier. Regardless of the substrate, the technology allows you to create high-quality and durable things. Still, for printers, it promises a long way associated with ink preparation. What colored fluids are used, why not every textile can withstand the reactive components of them, and how piezoelectric printing conquers the world read in this article [...]
ShipStation vs ShipHero - Comparing The Two Shipping Powerhouses
ShipStation and ShipHero are two major eCommerce shipping and fulfillment platforms that get the most buzz in today’s commercial market niches globally. Both provide unprecedented order management opportunities that help companies streamline their eCommerce activity and get higher sales rates. But while reports rate both solutions almost equally, it is important to understand these platforms fit certain types of businesses better than others. Moreover, there are more underlying aspects based on which you should make the final decision [...]
2021 Print on Demand in Canada and USA: Business Culture, Trends & Forecasts
Every time on the eve of presidential elections, many entrepreneurs threaten the authorities with leaving for Canada if their preferred candidate doesn’t win. The fact is that this country is one of the best for doing business, although it relies heavily on the USA economy. Multi-Programming Solutions figured out how reasonably it is to invest in a POD startup and how e-commerce trends affect sales in the countries with the most powerful economies. Thinking about the launch of print on demand in Canada, it’s worthy of note that in 2007, this country avoided the collapse of the banking system that hit the USA and Europe. Royal Bank of Canada, Bank of Nova Scotia, and Bank of Montreal escaped financial aid and remained profitable. A similar situation is observed now: in July 2020, the Canadian economy grew by 0.7%. Due to the low incidence of coronavirus, there’s every chance of recovering. In the USA, the economy returned to its previous position with a value of 33.4%. That was the best growth rate since 2003 [...]
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