2016-05-17 88 views
2

看到這麼:Peer not authenticated while importing Gradle project in eclipse如何更改Android Studio中的默認jcenter()值?

消除錯誤,在新的Android Studio項目我必須編輯的build.gradle如下:

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

原來jcenter()必須被註釋掉。當然,有一個地方可以在某處更改默認值,因此不再需要以這種方式更改每個項目。

+0

我在所引用的SO帖子中提出了一個問題,並且沒有人回答過。 – subjectivist

回答

0

我做了一個VBScript文件要做到這一點,下面粘貼,並處理以下路徑:創建一個新項目時\ Program Files文件\的Android \ Android Studio中\插件

沒有更多的問題jcenter:C。

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 
相關問題