第一次用Gradle Build Android就上手(悲劇)教學

主要介紹使用從eclipse建立出的project

使用Android Developer Tools Build: v22.2.1-833290
        gradle-1.8 => 記得先去設定好環境變數
先建好一個Android Project

在Project上按滑鼠右鍵選export這動作主要是要建立build.gradle


























在command下切到該project 下gradle clean 就悲劇了.......

照著他說地去設環境變數一點用都沒有........有人這方法成功請告訴我

解法

1.用Android Studio將該Project匯入他會產生必要的檔案Orz
or
2.自己加入必要檔案local.properties,該檔案就是設定你SDK的路徑

內容

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Nov 26 13:21:30 GMT+08:00 2013
sdk.dir=C\:\\Program Files (x86)\\Android\\android-studio\\sdk


同樣在Project位置下gradle clean








終於...接下來下gradle build


















到這Project底下就會產生bulid資料夾,第一次接觸到這算是成功囉!

下次再研究如何設定build不同apk

短短的幾行卻也花了不少時間,寫成文章又花了不少時間

如果有幫到忙就幫我的文章分享一下(+1)吧!

留言