当前位置:   article > 正文

maven gradle阿里云源_gradle plugin maven源

gradle plugin maven源

1.Android Studio中gradle版本未升级的情况(避免报错的首选方案)

with groovy

(1).build.gradle配置

  1. buildscript {
  2. repositories {
  3. //ADD START
  4. maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
  5. maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
  6. maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
  7. maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
  8. maven { url "https://maven.aliyun.com/repository/google" }
  9. maven { url "https://maven.aliyun.com/repository/public" }
  10. maven { url "https://maven.aliyun.com/repository/jcenter" }
  11. maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
  12. //ADD END
  13. google()
  14. jcenter()
  15. maven {
  16. url 'https://maven.google.com/'
  17. name 'Google'
  18. }
  19. }
  20. dependencies {
  21. classpath 'com.android.tools.build:gradle:3.6.3'
  22. }
  23. }
  24. allprojects {
  25. repositories {
  26. //ADD START
  27. maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
  28. maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
  29. maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
  30. maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
  31. maven { url "https://maven.aliyun.com/repository/google" }
  32. maven { url "https://maven.aliyun.com/repository/public" }
  33. maven { url "https://maven.aliyun.com/repository/jcenter" }
  34. maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
  35. //ADD END
  36. google()
  37. jcenter()
  38. maven {
  39. url "https://jitpack.io"
  40. }
  41. maven {
  42. url 'https://maven.google.com/'
  43. name 'Google'
  44. }
  45. maven { url "https://jitpack.io" }
  46. ......
  47. mavenCentral()
  48. }
  49. }

(2).C:\Users\LENOVO\.gradle\init.gradle配置

  1. allprojects{
  2. repositories {
  3. def MY_ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
  4. def MY_ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
  5. all { ArtifactRepository repo ->
  6. if(repo instanceof MavenArtifactRepository){
  7. def url = repo.url.toString()
  8. if (url.startsWith('https://repo1.maven.org/maven2')) {
  9. project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_REPOSITORY_URL."
  10. remove repo
  11. }
  12. if (url.startsWith('https://jcenter.bintray.com/')) {
  13. project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_JCENTER_URL."
  14. remove repo
  15. }
  16. }
  17. }
  18. maven {
  19. url MY_ALIYUN_REPOSITORY_URL
  20. url MY_ALIYUN_JCENTER_URL
  21. }
  22. }
  23. }

2.Android Studio中gradle版本已升级的情况(gradle升级可能jdk版本也需升级)

with groovy

(1).build.gradle配置

  1. buildscript {
  2. repositories {
  3. //ADD START
  4. maven {
  5. allowInsecureProtocol = true
  6. url 'http://maven.aliyun.com/nexus/content/groups/public/'
  7. }
  8. maven {
  9. allowInsecureProtocol = true
  10. url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
  11. }
  12. maven {
  13. allowInsecureProtocol = true
  14. url 'http://maven.aliyun.com/nexus/content/repositories/google'
  15. }
  16. maven {
  17. allowInsecureProtocol = true
  18. url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin'
  19. }
  20. maven {
  21. allowInsecureProtocol = true
  22. url 'https://maven.aliyun.com/repository/google'
  23. }
  24. maven {
  25. allowInsecureProtocol = true
  26. url 'https://maven.aliyun.com/repository/public'
  27. }
  28. maven {
  29. allowInsecureProtocol = true
  30. url 'https://maven.aliyun.com/repository/jcenter'
  31. }
  32. maven {
  33. allowInsecureProtocol = true
  34. url 'https://maven.aliyun.com/repository/gradle-plugin'
  35. }
  36. //ADD END
  37. google()
  38. mavenCentral()
  39. maven { url 'https://maven.google.com' }
  40. jcenter()
  41. }
  42. dependencies {
  43. classpath 'com.android.tools.build:gradle:7.0.0'
  44. }
  45. }
  46. allprojects {
  47. repositories {
  48. //ADD START
  49. maven {
  50. allowInsecureProtocol = true
  51. url 'http://maven.aliyun.com/nexus/content/groups/public/'
  52. }
  53. maven {
  54. allowInsecureProtocol = true
  55. url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
  56. }
  57. maven {
  58. allowInsecureProtocol = true
  59. url 'http://maven.aliyun.com/nexus/content/repositories/google'
  60. }
  61. maven {
  62. allowInsecureProtocol = true
  63. url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin'
  64. }
  65. maven {
  66. allowInsecureProtocol = true
  67. url 'https://maven.aliyun.com/repository/google'
  68. }
  69. maven {
  70. allowInsecureProtocol = true
  71. url 'https://maven.aliyun.com/repository/public'
  72. }
  73. maven {
  74. allowInsecureProtocol = true
  75. url 'https://maven.aliyun.com/repository/jcenter'
  76. }
  77. maven {
  78. allowInsecureProtocol = true
  79. url 'https://maven.aliyun.com/repository/gradle-plugin'
  80. }
  81. //ADD END
  82. google()
  83. mavenCentral()
  84. maven {
  85. url "https://jitpack.io"
  86. }
  87. maven { url 'https://maven.google.com' }
  88. jcenter()
  89. maven { url 'https://dl.google.com/dl/android/maven2' }
  90. }
  91. }
  92. task clean(type: Delete) {
  93. delete rootProject.buildDir
  94. }

(2).C:\Users\LENOVO\.gradle\init.gradle配置

  1. allprojects{
  2. repositories {
  3. def MY_ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
  4. def MY_ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
  5. all { ArtifactRepository repo ->
  6. if(repo instanceof MavenArtifactRepository){
  7. def url = repo.url.toString()
  8. if (url.startsWith('https://repo1.maven.org/maven2')) {
  9. project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_REPOSITORY_URL."
  10. remove repo
  11. }
  12. if (url.startsWith('https://jcenter.bintray.com/')) {
  13. project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_JCENTER_URL."
  14. remove repo
  15. }
  16. }
  17. }
  18. maven {
  19. allowInsecureProtocol = true
  20. url MY_ALIYUN_REPOSITORY_URL
  21. url MY_ALIYUN_JCENTER_URL
  22. }
  23. }
  24. }

3.with kotlin

  1. repositories {
  2. maven {
  3. isAllowInsecureProtocol = true
  4. setUrl("http://maven.aliyun.com/nexus/content/groups/public/")
  5. }
  6. maven {
  7. isAllowInsecureProtocol = true
  8. setUrl("http://maven.aliyun.com/nexus/content/repositories/jcenter")
  9. }
  10. maven {
  11. isAllowInsecureProtocol = true
  12. setUrl("http://maven.aliyun.com/nexus/content/repositories/google")
  13. }
  14. maven {
  15. isAllowInsecureProtocol = true
  16. setUrl("http://maven.aliyun.com/nexus/content/repositories/gradle-plugin")
  17. }
  18. maven {
  19. isAllowInsecureProtocol = true
  20. setUrl("https://maven.aliyun.com/repository/google")
  21. }
  22. maven {
  23. isAllowInsecureProtocol = true
  24. setUrl("https://maven.aliyun.com/repository/public")
  25. }
  26. maven {
  27. isAllowInsecureProtocol = true
  28. setUrl("https://maven.aliyun.com/repository/jcenter")
  29. }
  30. maven {
  31. isAllowInsecureProtocol = true
  32. setUrl("https://maven.aliyun.com/repository/gradle-plugin")
  33. }
  34. }

Android Studio gradle无法编译App的完美解决方法

Android Studio中gradle版本升级报gradle的仓库地址不安全警告

Android Studio中gradle版本是否升级的方案(选其一)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/237459
推荐阅读
相关标签
  

闽ICP备14008679号