最近AndroidStudio升級後出現了一些以前沒遇過的問題。
當我們要增加套件時,有時候需要增加套件來源,如jitpack.io等..
會有一像是要加在build.gradle
的allprojects
中,例如:
buildscript { repositories { maven { url 'https://jitpack.io' } } } allprojects { repositories { maven { url 'https://jitpack.io' } } }
這時如果進行Build,就會發生以下一堆錯誤了:
Build file 'C:\Users\xxxxx\Documents\xxxxx\build.gradle' line: 18 A problem occurred evaluating root project 'xxxxx'. > Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle' * Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights. ... ...
大致上看來這次改版後,不能使用allprojects
了。
那麼要如何新增套件庫來源?
已經改到settings.gradle
裡面了:
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() jcenter() // Warning: this repository is going to shut down soon //新的來源加在這邊 maven { url 'https://jitpack.io' } } } rootProject.name = "xxxxx" include ':app'
這樣就可以了。
-END-
發佈留言