android studio最基本的知識一

來源:互聯網
上載者:User

android studio最基本的知識一

最近看到身邊的很多android開發程式員都在使用android studio,於是自己也下了個嘗試怎麼使用。其實這個開發工具在2013年我就知道了,那時由於自己太懶了,就沒有使用它。現在發現如果不會使用android studio在以後的android開發中肯定是一大問題! 下面是自己在使用中遇到的問題和大家分享下。

1。Eclipse使用習慣的程式員,在初次接觸到android Studio(以下簡稱as)時肯定無從下手,為什麼這麼說呢?在Eclipse中有個工作空間(workspace)這個裡面可以建立很多的Project,但是在as中如果你第一使用肯定很不習慣,發現找不到workspace。這是你可以選擇這裡的Project或者android(選擇android後as會合并res中的檔案夾)。在Scopes下面還有好幾個選項,讀者自己試試就會明白的。

2。build.gradle檔案我在第一次接觸到as時就看了很多的關於gradle的介紹,都沒有解決我所的問題。以下是預設的build.gradle檔案

buildscript {    repositories {       jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:1.0.0'        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {      jcenter()    }}
如果在一個項目裡的build.gradle中的dependencies 添加這樣的代碼

 

 

    compile 'com.android.support:appcompat-v7:21.0.3'    compile 'com.squareup.dagger:dagger:1.2.2'    compile 'com.squareup.dagger:dagger-compiler:1.2.2'    compile 'com.jakewharton:butterknife:6.0.0'    compile 'com.squareup.retrofit:retrofit:1.9.0'    compile 'com.android.support:support-v4:21.0.3'    compile 'com.android.support:appcompat-v7:21.0.3'
前提是你的網可以訪問到國外的網路,不然你的項目在gradle不成功,會報錯(注意如果你的配置和上面的一模一樣在使用compile時需要能訪問到國外網路)。當然還有另外一個辦法如下

 

 

buildscript {    repositories {        mavenCentral()        maven{            url file://E:/githubrepo/releases        }        //或者使用指定的遠程maven庫        maven{            url http://mvnrepository.com/        }    }    dependencies {        classpath 'com.android.tools.build:gradle:1.0.0'        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        mavenCentral()    }}
把上面的jcenter改為mavenCenter,並且加上url就不需要訪問到國外網路了,輕鬆解決。
以上就是我為剛接觸到as的新手一點的分享,如果寫的不好歡迎廣大程式員朋友給我留言!最後希望在接觸到新東西時,不要有一種不願意接受的心理,要是第一個吃螃蟹的人,因為在程式員裡面 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.