Search code examples
androidclasscompilationdex

How to import classes from an dex file in Android Studio


I'm trying to import a framework from a third-party project and include it in my project. But when I import the module (using Android Studio), the classes are inside a "classes.dex" file, and I can't import them in my project like as below:

import android.os.ThirdPartyClass

There are other libraries, but the classes are compiled into .class and not included in a .dex file, so I can import without any problems.

How can I import in this case of .dex file?


Solution

  • PREFACE

    This method was deprecated in API level 26. Applications should use one of the standard classloaders such as PathClassLoader instead. This API will be removed in a future Android release.

    CONVERTING

    You can compile that .dex file into a .java file.

    Here is a manual how to achieve that. It's really easy and I think answered your question. Good luck! :)