Search code examples
androidgradle

Copy Android Studio plugins to offline network


I have a gradle project which I've transferred to a network that has no internet access. To resolve all of my dependencies, I've grabbed the files in ~/.gradle/caches/modules-2/files-2.1 and pushed them to my network's Artifactory.

However, when I run ./gradlew build, I get the error

* What went wrong
Plugin [id: 'com.android.application', version: '8.2.1', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.2.1')
  Searched in the following repositories:
    my-repo(https://my.artifactory/my-repo/gradle)

In my-repo, I have the following:

gradle/
  com.android.application/
    com.android.application.gradle.plugin/
      8.2.1/
        <some hash>/
          com.android.application.gradle.plugin-8.2.1.pom

How can I get gradle to find the plugin?


Solution

  • Those are the files you need but you need to put them in the proper structure. For example, given the directory structure above, you'd need to change it to

    gradle/
      com/
        android/
          application/
            gradle/
              plugin/
                8.2.1/
                  com.android.application.gradle.plugin-8.2.1.pom