# How to add a JAR file to a C++ Qt Widgets for Android project?

**URL:** <https://discourse.cmake.org/t/how-to-add-a-jar-file-to-a-c-qt-widgets-for-android-project/597>\
**Category:** Code\
**Created:** [February 7, 2020, 10:50am UTC](https://discourse.cmake.org/t/how-to-add-a-jar-file-to-a-c-qt-widgets-for-android-project/597 "2020-02-07T10:50:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Ben\_Cottrell](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ben_cottrell/32/1180_2.png) [@Ben\_Cottrell](https://discourse.cmake.org/u/Ben_Cottrell)\
**Post date:** [February 5, 2021, 9:04pm UTC](https://discourse.cmake.org/t/how-to-add-a-jar-file-to-a-c-qt-widgets-for-android-project/597/2 "2021-02-05T21:04:09Z")

</div>

Qt Creator uses the android deployment tool which copies certain files to the Android package. You can specify the package directory in your CMakeLists.txt file with:

```auto
if (ANDROID)
     set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
endif()

```

You can create this directory along with template files in android by clicking “Create Templates” under Projects Mode (Ctrl+Five), “Build Steps” in “Build Android APK”.

In the “android” directory you can specify which JAR files to bundle in “build.gradle”, similar to the following:

```auto
dependencies {
    compile files('path/local_dependency.jar')
}

```

That was taken from [https://riptutorial.com/gradle/example/8349/add-a-local-jar-file-dependency](https://riptutorial.com/gradle/example/8349/add-a-local-jar-file-dependency)

---

_[View the full topic](https://discourse.cmake.org/t/how-to-add-a-jar-file-to-a-c-qt-widgets-for-android-project/597)._
