岩手からこんにちは ☆彡 perl とかウェブ系なブログ

はてなダイアリーからひっこしましたよ http://d.hatena.ne.jp/rosiro

phonegap and Android Studio on Mac OSX Mountain Lion


macでAndroidでphongapです。
以前はelipse使っていましたがAndroid studioを使ってみようとおもいました。 Android Studio(略:あんすた)正直どうなのかよくわかってませんがeclipseのあの感じよりはいいのかなと思いまして使ってみました。

Android Studio http://developer.android.com/sdk/installing/studio.html
のダウンロード・インストール
/Applications/Android\ Studio.app/sdk/
sdkがインストールされる

ls /Applications/Android\ Studio.app/sdk/tools/
Jet               ddms              emulator-x86      hprof-conv        monkeyrunner      templates
NOTICE.txt        dmtracedump       emulator64-arm    jobb              proguard          traceview
adb_has_moved.txt draw9patch        emulator64-mips   lib               source.properties uiautomatorviewer
android           emulator          emulator64-x86    lint              sqlite3           zipalign
ant               emulator-arm      etc1tool          mksdcard          support
apps              emulator-mips     hierarchyviewer   monitor           systrace

次にパスを通す。 通さないとあとで困ることになるだ。
export PATH=${PATH}:/Applications/Android\ Studio.app/sdk/tools:/Applications/Android\ Studio.app/sdk/platform-tools

インストール

nodejsのダウンロードインストール
http://nodejs.org/

nstall the cordova utility. In Unix, prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
>>|
sudo npm install -g cordova
|

所有権を変更
To ensure permissions are correct, run this command on Mac or Linux, changing LOGIN to match your account name:

$ sudo chown -R アカウント名 /usr/local/lib/node_modules/cordova

cordova utilityのアップデート
After installing the cordova utility, you can always update it to the latest version by running the following command:

    $ sudo npm update -g cordova

Use this syntax to install a specific version:

    $ sudo npm install -g cordova@2.9.0

インストールされたcordova情報を見る

sudo npm info cordova

インストール完了っ

アプリを作る

cordova create HelloWorld com.example.hello "Hello World"

つくったった

cd HelloWorld
tree
.
├── merges
├── platforms
├── plugins
└── www
    ├── config.xml
    ├── css
    │   └── index.css
    ├── img
    │   └── logo.png
    ├── index.html
    ├── js
    │   └── index.js
    ├── res
    │   ├── icon
    │   │   ├── android
    │   │   │   ├── icon-36-ldpi.png
    │   │   │   ├── icon-48-mdpi.png
    │   │   │   ├── icon-72-hdpi.png
    │   │   │   └── icon-96-xhdpi.png
    │   │   ├── bada
    │   │   │   └── icon-128.png
    │   │   ├── bada-wac
    │   │   │   ├── icon-48-type5.png
    │   │   │   ├── icon-50-type3.png
    │   │   │   └── icon-80-type4.png
    │   │   ├── blackberry
    │   │   │   └── icon-80.png
    │   │   ├── ios
    │   │   │   ├── icon-57-2x.png
    │   │   │   ├── icon-57.png
    │   │   │   ├── icon-72-2x.png
    │   │   │   └── icon-72.png
    │   │   ├── tizen
    │   │   │   └── icon-128.png
    │   │   ├── webos
    │   │   │   └── icon-64.png
    │   │   └── windows-phone
    │   │       ├── icon-173-tile.png
    │   │       ├── icon-48.png
    │   │       └── icon-62-tile.png
    │   └── screen
    │       ├── android
    │       │   ├── screen-hdpi-landscape.png
    │       │   ├── screen-hdpi-portrait.png
    │       │   ├── screen-ldpi-landscape.png
    │       │   ├── screen-ldpi-portrait.png
    │       │   ├── screen-mdpi-landscape.png
    │       │   ├── screen-mdpi-portrait.png
    │       │   ├── screen-xhdpi-landscape.png
    │       │   └── screen-xhdpi-portrait.png
    │       ├── bada
    │       │   └── screen-portrait.png
    │       ├── bada-wac
    │       │   ├── screen-type3.png
    │       │   ├── screen-type4.png
    │       │   └── screen-type5.png
    │       ├── blackberry
    │       │   └── screen-225.png
    │       ├── ios
    │       │   ├── screen-ipad-landscape-2x.png
    │       │   ├── screen-ipad-landscape.png
    │       │   ├── screen-ipad-portrait-2x.png
    │       │   ├── screen-ipad-portrait.png
    │       │   ├── screen-iphone-landscape-2x.png
    │       │   ├── screen-iphone-landscape.png
    │       │   ├── screen-iphone-portrait-2x.png
    │       │   ├── screen-iphone-portrait-568h-2x.png
    │       │   └── screen-iphone-portrait.png
    │       ├── tizen
    │       │   └── README.md
    │       ├── webos
    │       │   └── screen-64.png
    │       └── windows-phone
    │           └── screen-portrait.jpg
    ├── spec
    │   ├── helper.js
    │   ├── index.js
    │   └── lib
    │       └── jasmine-1.2.0
    │           ├── MIT.LICENSE
    │           ├── jasmine-html.js
    │           ├── jasmine.css
    │           └── jasmine.js
    └── spec.html

29 directories, 55 files

なにやらテンプレっぽいアプリをつくってくれる。

プラットフォームをどうすんの

    $ cordova platform add ios
    $ cordova platform add android
    $ cordova platform add blackberry
Run any of these from a Windows machine, where wp refers to different versions of the Windows Phone operating system:

    $ cordova platform add wp7
    $ cordova platform add wp8
    $ cordova platform add android
    $ cordova platform add blackberry
cordova platform add android

あとはandroid studioでimport projectでさっきひな形をつくった場所を指定すればいけるぞ!