Android Studio: Configure offline build dependencies

大城市里の小女人 提交于 2020-05-17 07:45:06

问题


Good day, I followed the instructions in the "Configure you Android Studio Page" to install offline build dependencies(found here https://developer.android.com/studio/intro/studio-config#offline). Downloaded the gradle plugin and the maven dependencies, unzipped them into the required folder, and also created the offline.gradle file, putting it in the appropriate folder. However, in the guide, it was said that to test it is working, one needs to comment the repositories in the build.gradle file. The problem is once I do this. My project fails to build.

I would appreciate any help with this. My SDK : Android 10(API 29) What I know: The android gradle plugin(I downloaded from the main site) is 3.5.0-beta01

When I check .android/manual-offline-m2/gmaven_stable/com/android/tools/build/gradle/ I see folders ranging from 3.0.0 to 3.4.0

The classpath in dependencies (in the build.gradle of my app) is 'com.android.tools.build:gradle:3.6.1'

The distributionUrl (gradle-wrapper.properties) points to https://services.gradle.org/distributions/gradle-5.6.4-all.zip

The ERROR I get says: A problem occured configuring root project 'TestingOfflineBuildApp'. Could not resolve all artifacts for configuration ':classpath'. Could not find com.android.tools.build:gradle:3.6.1. Searched in the following locations:

If I change the classpath from 3.6.1 to 3.5.0-beta01, the errors change to this(second pic). Error 1 Error 2 Thank you


回答1:


You don't need to change anything after configuring offline build dependencies, the error you getting is by putting comments on build.gradle file (i think there is exception in this documentation step 4 (optional) and that exception is [ internet is required one time for "new Android Gradle Plugin" version download if it is not present in local repo or cache ] ).

The Solution is

  1. (If error shows like this with "correct location of our set repo in local repo", then its fine,our setting is working fine) image: Error Shows like this

  2. Uncomment the comments which we commented earlier, classpath and other things should be same ,no need to change. image: Build Successfully


Notes:- (follow this if offline build failed occurs after doing above steps)

  • Whichever android gradle plugin version set in CLASSPATH of build.gradle file [internet is required one time for "new Android Gradle Plugin" version download if it is not present in local repo or cache]
  • “offline.gradle” init scripts in “init.d” directory is executed at the start of the build.
  • For more details you can read from here https://developer.android.com/studio/build/dependencies

  • For more details about Maven vs Gradle https://dzone.com/articles/gradle-vs-maven



来源:https://stackoverflow.com/questions/60894945/android-studio-configure-offline-build-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!