如何在Android Studio中更改默认的jcenter()值? [英] How do I change the default jcenter() value in Android Studio?

查看:298
本文介绍了如何在Android Studio中更改默认的jcenter()值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参见SO:在以下位置导入Gradle项目时未对等身份验证蚀

要消除错误,在新的Android Studio项目中,我必须按以下方式编辑build.gradle:

To eliminate errors, in new Android Studio projects I must edit build.gradle as follows:

    //jcenter()
    jcenter {
        url "http://jcenter.bintray.com/"
    }

原始jcenter()必须被注释掉.当然,可以在某个地方更改默认值,因此不再需要以这种方式更改每个项目.

The original jcenter() must be commented out. Surely there's a place to change the default value somewhere so it is no longer necessary to change each project in this manner.

推荐答案

我制作了一个vbscript文件来做到这一点,粘贴在下面,并处理了以下路径:C:\ Program Files \ Android \ Android Studio \ plugins

I made a vbscript file to do this, pasted below, and processed the following path: C:\Program Files\Android\Android Studio\plugins

创建新项目时,jcenter不再存在问题.

No more problem with jcenter when creating a new project.

const ToRead = 1
const ToWrite = 2
const ToAppend = 8
edit_path = ""
if wscript.arguments.count > 0 then edit_path = trim(wscript.arguments.item(0))
if left(edit_path,1) = """" then edit_path = mid(edit_path,2)
if right(edit_path,1) = """" then edit_path = left(edit_path,len(edit_path)-1)
if len(edit_path) = 0 then
  msgbox "Drag and drop the folder onto this script file to process it"
  wscript.quit
  end if
set fso = createobject("Scripting.FileSystemObject")
dim reader,writer
if not fso.folderexists(edit_path) then
  msgbox "folder not found"
  wscript.quit
  end if
count = 0
if msgbox("The following path will be processed" & vbcrlf & _
          edit_path & vbcrlf & vbcrlf & _
          "Continue?",vbyesno) = vbyes then
  scan edit_path
  msgbox count & " files edited"
  end if

sub scan(path)
  set files = fso.getfolder(path).files
  for each f in files
    if lcase(right(f.name,11)) = ".gradle.ftl" then edit_file path & "\" & f.name
  next
  set folders = fso.getfolder(path).subfolders
  for each f in folders : scan path & "\" & f.name : next
end sub

sub edit_file(file_name)
  set reader = fso.opentextfile(file_name,ToRead)
  a = ""
  if not reader.atendofstream then a = reader.readall
  reader.close
  found = false
  sw = true
  while sw
    sw = false
    p = instr(1,a,"  jcenter()" & vblf,vbtextcompare)
    if p > 0 then
      q = instrrev(a,vblf,p)
      if q > 0 then
        sw = true
        found = true
        spacing = p - q + 1
        a = left(a,q) & space(spacing) & "//jcenter()" & vblf & _
                        space(spacing) & "jcenter {" & vblf & _
                        space(spacing) & "    url ""http://jcenter.bintray.com/""" & vblf & _
                        space(spacing) & "}" & mid(a,p+11)
        end if
      end if
    wend
  if found then
    count = count + 1
    fso.movefile file_name,file_name & ".save"
    set writer = fso.createtextfile(file_name)
    writer.write a
    writer.close
    end if
end sub

这篇关于如何在Android Studio中更改默认的jcenter()值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆