菜单

Android Studio

grandle Google IO

2014

打包 .so 文件的技巧

https://groups.google.com/forum/?fromgroups#!topic/adt-dev/nQobKd2Gl_8

Overview

Google I/O 2013 放出的新 Android SDK,基于 Intellij IDEA。现在还只是早期预览版本。

https://developer.android.com/sdk/installing/studio.html

http://android-developers.blogspot.com/2013/05/android-studio-ide-built-for-android.html

是否要切换到 Android Studio?

优点

缺点

intellij idea

Quick Start 30天 Guide 是很好的入门阅读材料

Help->Productivity Guide 提升效率的好帮手

先熟悉 IntelliJ IDEA

IntelliJ 的 project 概念跟 Eclipse 的 project 不一样.它的 module 才是类似于 Eclipse 的 project,而他的 project 则类似于 Eclipse 的 workspace

https://developer.android.com/sdk/installing/studio-tips.html https://www.jetbrains.com/idea/index.html

项目结构

http://confluence.jetbrains.com/display/IDEADEV/Structure+of+IntelliJ+IDEA+Project

Project

封装源码,库的一个组织单元。IntelliJ 所以操作的上下文环境,可以包含一个或者多个模块。

Module

模块是一个可单独运行,测试,debug 的离散单元。

Library

TODO 各个文件的作用

基本设置

更改默认换行符

https://www.jetbrains.com/idea/webhelp/configuring-line-separators.html

将文件编码改为 utf-8

Alt + Ctrl + I 修复当前行的缩进(Auto-Indent Lines)

Alt + F7 Find Usage(全部项目)

Alt +Ctrl + F7 使用 popup 显示 FindUsage 结果

Shift + Ctrl + F7 高亮结果

Ctrl + F12 Structure 类似 Eclipse Quick Outline (居然找不到关闭的快捷键)

Ctrl + Alt + Shift + N 快速跳转到任一个 symbol

template

默认有 sout 使用 C-j 进行补全

不明白eclipse 为什么用 sysout

http://arhipov.blogspot.jp/2011/07/whats-cool-in-intellijidea-part-ii-live.html https://www.jetbrains.com/idea/features/code_generation.html

Emacs Keymap

option 解决办法

用一个新的 keyboard layout 屏蔽掉 option 的输入字符快捷键,才能在 intellij 中作为meta 键使用。

按照 @dan 的方法实现 http://stackoverflow.com/questions/11876485/how-to-disable-typing-special-characters-when-pressing-option-key-in-mac-os-x

但是新的 layout 不支持 aquamacs

来回切换也麻烦

C-X,B

Emacs Keymap 中 C-X,B 默认是打开 Switcher 的,但是 Switcher 不支持这种打开方式,这是个比较特殊的功能,详见官方文档:Navigating Between Files and Tool Windows

Switcher 只能使用默认快捷键,Ctrl+Tab

git

用我这个 .gitignore

有个很方便的 VCS operations quick list(M-`, Ctrl + V for Mac))

直接用 cygwin 的 git.ext

http://shrubbery.homeip.net/c/display/W/Using+GIT+with+IntelliJ+IDEA

插件

https://github.com/inmite/android-selector-chapek

https://github.com/Haehnchen/idea-android-studio-plugin

https://bitbucket.org/bric3/jd-intellij

ActionBarSherlock

尝试了多种情况,只有 @froger_mcs 的方法是可行的,说明也足够详细。 http://stackoverflow.com/a/16639227/851344

不过关于android-support-v4.jar,得按照留言中 @Akbar 的配置才行。

不过运行的时候仍会提示错误

Gradle 执行 aapt 出错,CreateProcess error=8

gradle clean

gradle compileDebug --info

就没问题了.

错误: 编码GBK的不可映射字符

Gradle

Gradle 是什么

http://www.gradle.org/docs/current/userguide/userguide_single.html#overview

http://stackoverflow.com/questions/1163173/why-use-gradle-instead-of-ant-or-maven

new android sdk build system

https://www.youtube.com/watch?v=LCJAgPkpmR0

http://tools.android.com/tech-docs/new-build-system/user-guide

貌似只支持1.6

Gradle wrapper

The Gradle Wrapper allows you to execute Gradle builds on machines where Gradle is not installed.

Bug

1

运行项目找不到模块(module)

2

自己更改项目路径就会出现 There must not already be a project at this location.

3

http://tools.android.com/knownissues

弄了一整天还是不能将源码导入作为andriod library ,提示

Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shanbay-reader-android:compileDebug'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

这个错误是因为找不到类 AsyncHttpClient,发现将 jar 添加进module后,build.gradle 里的 dependencies 里仍没有该文件。

参考 http://binizzio.com/?p=227

compile fileTree(dir: 'libs', include: '*.jar')

仍然需要手动编辑 build.gradle

然后必须gradle clean 不然还是会提示找不到类。

参考:http://stackoverflow.com/questions/16718026/how-to-build-an-android-library-with-android-studio-and-gradle