zoukankan      html  css  js  c++  java
  • Android Studio安装及其使用

    为了不与Java开发混用,所以不使用IDEA开发安卓应用而选择Android Studio。

    官网下载安装 Android Studio(https://developer.android.google.cn/studio/)

    启动时会提示 Unable to access Android SDK add-on list,点 cancel,然后就会弹出Android SDK和其他组件的下载窗口,这时下载即可。

    dl.google.com已经不被墙了,现在直连速度就很快。如果速度很慢或者连不上,请修改DNS

     

    Android Studio下载的SDK默认会在 C:Users当前用户AppDataLocalAndroidSdk

    (AppData目录是带隐藏属性的,请打开显示隐藏文件(夹))

     在 Default Project Structure... 里可以配置/下载Android SDK和NDK

     如何确认网络连接有效呢?点一下Plugins,如果Marketplace里能显示在线插件,则代理有效。

    关于Android Studio默认的Gradle

     可以看到默认用得是wrapper{善用搜索引擎可找到路径在 C:Users用户名.gradlewrapperdistsgradle-5.1.1-all97z1ksx6lirer3kbvdnt7jtjg(这个目录名随机)gradle-5.1.1  }

    但是没有配置环境路径,也就是说这个Gradle只有Android Studio在用

    根据 "C:Users用户名.gradlewrapperdistsgradle-5.1.1-all97z1ksx6lirer3kbvdnt7jtjggradle-5.1.1init.d eadme.txt" 的指示,等等,这一步还没测试成功,请直接看下面的"项目Gradle配置"

    我们还可以自己编写 init.gradle 文件并放在此目录下用于自动化配置

    项目Gradle配置

    如果只想对项目生效,只需修改项目下的build.gradle文件

    buildscript {
    repositories {
    里google()和jcenter()的上面 添加如下两行即可:
    // 添加阿里云 maven 地址
    maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
    maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }

    效果:

     完整简单项目下的build.gradle

     1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
     2 
     3 buildscript {
     4     repositories {
     5 
     6         // 添加阿里云 maven 地址
     7         maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
     8         maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
     9 
    10         // jcenter()
    11         google()
    12     }
    13     dependencies {
    14         classpath 'com.android.tools.build:gradle:3.4.2'
    15         // NOTE: Do not place your application dependencies here; they belong
    16         // in the individual module build.gradle files这里的3.4.2是和gradle 5.1.1对应的,请勿随便修改
    17     }
    18 }
    19 
    20 allprojects {
    21     repositories {
    22 
    23         // 添加阿里云 maven 地址
    24         maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
    25         maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
    26 
    27         // jcenter()
    28         google()
    29     }
    30 }
    31 
    32 task clean(type: Delete) {
    33     delete rootProject.buildDir
    34 }
    View Code

    附上:

    Gradle、Maven使用阿里云镜像-阿里官方文档  https://help.aliyun.com/document_detail/102512.html

    如果出现

    ERROR: Failed to install the following Android SDK packages as some licences have not been accepted.
    build-tools;28.0.3 Android SDK Build-Tools 28.0.3
    platforms;android-28 Android SDK Platform 28
    To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
    Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

    Using Android SDK: C:UsersxxAppDataLocalAndroidSdk

    ,点 Install missing SDK package(s)即可

    SDK对应的版本配置可在Settings里搜索SDK

    相对布局使用方法:

    要关闭这个 自动吸附父控件

    才能调整拖放的控件距离

     然后长按这些,可以设置相对哪个控件放置及其相对距离

    This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you

    原因是没有设置约束,约束布局是结合了相对布局并改进的新特性,所以如上图设置相对的方法也可用于约束布局

    或者点一下按钮:https://blog.csdn.net/BSSYNHDJZMH/article/details/79728625#解决方案

    --------蓝天上的云_转载请注明出处.
  • 相关阅读:
    深拷贝与浅拷贝+可变与不可变的数据类型
    列表+列表循环+列表切片+元祖
    接口+session与cookie的区别+http状态码
    JSP中文乱码问题终极解决方案
    关于AS使用git的那些奇葩事儿
    ListView中动态显示隐藏HeaderView和FooterView
    关于沉浸式的那些奇葩问题
    Android Bug分析系列:第三方平台安装app启动后,home键回到桌面后点击app启动时会再次启动入口类bug的原因剖析
    快速搭建tab
    使用 gradle 在编译时动态设置 Android resValue / BuildConfig / Manifes中<meta-data>变量的值
  • 原文地址:https://www.cnblogs.com/yucloud/p/12049914.html
Copyright © 2011-2022 走看看