AndroidStudio介绍,代理配置,特性,技巧及从eclipse迁移到as
来源:互联网 发布:拍证书的软件 编辑:程序博客网 时间:2024/06/06 19:55
Android Studio视图
前言:
Android Studio 是google官方正式开发Android应用程序的开发工具,这玩意是基于IntelliJ IDEA,AndroidStudio 提供如下功能:
Flexible Gradle-based build system Build variants and multiple apk file generation Code templates to help you build common app features Rich layout editor with support for drag and drop theme editing lint tools to catch performance, usability, version compatibility, and other problems ProGuard and app-signing capabilities Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine And much more
简单说:
灵活的gradle编译系统
编译变量和多apk的生成(变量是指不同产品的标识,比如debug和release)
代码模板帮助我们构建具有相同特性的app
支持布局拖拽和主题编辑的布局编译器
line tools 工具
签名支持
google 云平台
For specific Android Studio how-to documentation, see the pages in the Workflow section, such as Managing Projects from Android Studio and Building and Running from Android Studio. For a summary of the latest changes to Android Studio, see the Android Studio Release Notes.
如果你用as做Android开发,可以看看这些workflow这部分文档,比如在as中管理工程,编译和运行app以及as的历史版本。
1,Project and File Structure 工程目录结构及对应的文件结构
Project 整个工程目录结构
Packages每个项的目目录结构,包含src和res
Android每个项目的目录结构,包含src,res, manifests和整体的gradle配置文件
2,Android Build System Android编译系统,也就是使用gradle
3,Debug and Performance 调试及各种性能工具
Android Studio provides a number of improvements to assist you in debugging and improving the performance of your code, including an improved virtual device management, inline debugging, and performance analysis tools.
4,Android Virtual Device (AVD) Manager 模拟器管理
5,Inline debugging 调试
6,Memory and CPU monitor 内存和cpu监听
7,Heap dump 内存镜像,可以看到内存的
8,Allocation tracker 内存分配和跟踪
9,Data file access 数据存储
10,Code inspections 代码检查及命令行模式
11,Annotations in Android Studio 注解包的依赖
12,Inferring nullability 在你使用分析工具的时候,null的验证
To run a nullability analysis in Android Studio, select the Analyze > Infer Nullity menu option. Android Studio inserts the Android @Nullable and @NonNull annotations in detected locations in your code. After running a null analysis, it’s good practice to verify the injected annotations.
13,Log messages log信息
AndroidStudio Configuration
SDK Manager 更新配置
Settings –>Appearance –>System Settings–> Updates
Update channels 更新渠道
Canary channel: 二进制Dev channel: 开发Beta channel: 测试Stable channel: 稳定
Proxy Settings 代理配置:
For application-specific HTTP proxy settings, set the proxy settings in the build.gradle file as required for each application module.
每个app的配置:
apply plugin: 'com.android.application'android { ... defaultConfig { ... systemProp.http.proxyHost=proxy.company.com systemProp.http.proxyPort=443 systemProp.http.proxyUser=userid systemProp.http.proxyPassword=password systemProp.http.auth.ntlm.domain=domain } ...}
For project-wide HTTP proxy settings, set the proxy settings in the gradle/gradle.properties file.
整个工程的配置:
# Project-wide Gradle settings....systemProp.http.proxyHost=proxy.company.comsystemProp.http.proxyPort=443systemProp.http.proxyUser=usernamesystemProp.http.proxyPassword=passwordsystemProp.http.auth.ntlm.domain=domainsystemProp.https.proxyHost=proxy.company.comsystemProp.https.proxyPort=443systemProp.https.proxyUser=usernamesystemProp.https.proxyPassword=passwordsystemProp.https.auth.ntlm.domain=domain...
Features
不做过多介绍:
Translations Editor i18N的适配编辑器
Android Wear and TV support 手环和tv开发的支持
Fingerprint Support 指纹识别的支持
Developer Services google 的开发服务
Ads using AdMobAnalytics Google AnalyticsAuthentication using Google Sign-inNotifications using Google Cloud Messaging
Public and Private Resources 公用私有资源,这个值得研究
Tips and Tricks
开发技巧和秘籍:部分快捷键,反编译,注解,布局的所有机型视图
Migrating from Eclipse ADT
迁移工作,从eclipse迁移到AndroidStudio
Project Structure 工程目录:
整体对比:
目录结构对比图:
Mainfest对比:
Application ID for package identification
apply plugin: 'com.android.application'android { compileSdkVersion 19 buildToolsVersion "19.1" defaultConfig { applicationId "com.example.my.app" minSdkVersion 15 targetSdkVersion 19 versionCode 1 versionName "1.0" } ...
Build variants 不同包名打包配置:
productFlavors { pro { applicationId = "com.example.my.pkg.pro" } free { applicationId = "com.example.my.pkg.free" }}buildTypes { debug { applicationIdSuffix ".debug" }}....
Dependencies 依赖库
dependencies { /* ,exclude: 'android-support-v13.jar'' */ /*哪个jar不被编译*/ compile fileTree(dir: 'libs', include: ['*.jar']) /*compile files('libs/*.jar')*/ compile 'com.android.support:appcompat-v7:22.0.0' // 可以不适用appcompat-v7}
// Module dependency 依赖库 compile project(":lib") // Remote binary dependency compile 'com.android.support:appcompat-v7:19.0.1' // Local binary dependency 本地jar compile fileTree(dir: 'libs', include: ['*.jar'])
Gradle-based Build Process gradle 命令
assembleassembleDebugassembleRelease
直接在Terminal 中输入gradlew assemble
这个会下载对应的gradle版本:
对应的配置在 gradle\wrapper\gradle-wrapper.properties
#Wed Apr 10 15:27:10 PDT 2013distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
如果想看所有的命令: Gradle 默认在右边
Using the Android Studio build system’s declarative logic
宏定义
def getVersionCode) { def code = … return code}android { defaultConfig { versionCode getVersionCode() … }}
Resource Optimization res优化
Resource shrinking res缩减
android { ... buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }}
Filtering language resources 语言资源过滤:
apply plugin: 'android'android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 8 targetSdkVersion 22 versionCode 1 versionName "1.0" resConfigs "en", "de", "es" //Define the included language resources. resConfigs "mdpi", "hdpi" }...
Files to ignore 忽略文件配置:
A number of Android Studio files are typically not added to version control as these are temporary files or files that get overwritten with each build. These files are listed in an exclusion file, such as .gitignore, for the project and each app module. Typically, the following files are excluded from version control:
.gradle/local.properties/.idea/workspace.xml/.idea/libraries.DS_Store/build/captures
- AndroidStudio介绍,代理配置,特性,技巧及从eclipse迁移到as
- 从Eclipse迁移到AndroidStudio
- 如何从Eclipse迁移到AndroidStudio
- 如何从Eclipse迁移到AndroidStudio
- 如何从Eclipse迁移到AndroidStudio
- 项目从eclipse迁移到as
- 如何从Eclipse迁移到AndroidStudio(两种方式)
- 从Eclipse到AndroidStudio(五)迁移一个eclipse工程到AndroidStudio有哪些坑
- 从EclipseADT迁移到AndroidStudio
- as--eclipse迁移到as中
- 从Eclipse到AndroidStudio(二)界面介绍
- Eclipse项目迁移到AndroidStudio(一)
- Eclipse项目迁移到AndroidStudio(二)
- 把Eclipse项目迁移到AndroidStudio
- 把Eclipse项目迁移到AndroidStudio
- 从Eclipse到AndroidStudio(四)Gradle基本配置
- 从Eclipse到AndroidStudio(四)Gradle基本配置
- RecyclerView从配置到实现(eclipse and AndroidStudio)
- Spark 综合应用
- Android各种屏幕分辨率(VGA、HVGA、QVGA、WQVGA、WVGA、FWVGA) 详解
- 元编程笔记
- Android:Activity:生命周期
- java中判断一个字符串是否“都为数字”和“是否包含数字”和“截取数字”
- AndroidStudio介绍,代理配置,特性,技巧及从eclipse迁移到as
- Inbox (100500)
- [转]MySQL 5.7 新特性大全和未来展望
- [leetcode] 229. Majority Element II 解题报告
- How to create a Maven web app and deploy to Tomcat - fast
- java.net.UnknownHostException
- JQuery调用iframe子页面函数/对象的方法
- Struts2 集成 sitemesh配置
- Android中无返回值的页面跳转