How can I add an APK as dependency in my project in Android Studio?
Asked
Active
Viewed 674 times
1
-
convert your project into library and use it as dependency – Manohar Jun 08 '18 at 10:40
-
1why would you need it? how are you going to use that APK? – Vladyslav Matviienko Jun 08 '18 at 10:48
-
I need to use some methods from this apk project (I do not have source code), so I need to add it as dependency. – Jun 08 '18 at 12:35
-
Possible duplicate of [How to use my custom library apk file in other applications](https://stackoverflow.com/questions/1389435/how-to-use-my-custom-library-apk-file-in-other-applications) – rmalviya Jun 08 '18 at 13:50
1 Answers
4
You can't do that. Acceptable types are .jar
and .aar
and internal library project module.
Best you can do is to change the app-module to library module and then include it as depenancy.
You can achieve it as follows:
- Open the module-level
build.gradle
file. - Delete the line for the
applicationId
. Only an Android app module can define this. At the top of the file, you should see the following:
apply plugin: 'com.android.application'
Change it to the following:
apply plugin: 'com.android.library'
Save the file and click File > Sync Project with Gradle Files.

Sagar
- 23,903
- 4
- 62
- 62
-
Thanks for your reply. I do not have source code for this apk in order to build it in a different way. Is there a way to get the source code? – Jun 08 '18 at 12:36
-
@cthem Unfortunately you can't do that. If its internal you can request for source code from the team. But since its external, you can't – Sagar Jun 27 '18 at 07:45