zoukankan      html  css  js  c++  java
  • Android Studio从2.3升级到3.1注意事项

    原文:https://blog.csdn.net/lithiumyoung/article/details/80111111

    Android Studio从2.3升级到3.1注意事项

    • 项目根目录下的build.gradle 
      1.buildscript和allprojects的repositories中添加google() 
      2.dependencies中的classpath中将gradle版本修改为对应版本,如3.1.2

      buildscript {
          repositories {
              google()
              jcenter()
          }
          dependencies {
              classpath 'com.android.tools.build:gradle:3.1.2'
          }
      }
      
      allprojects {
          repositories {
              google()
              jcenter()
          }
      }
      
    • module目录下的build.gradle 
    • 1.删除buildToolsVersion。Android Studio3.0之后不需要再指定buildToolsVersion,每个版本的Android Gradle插件都有默认版本的构建工具,不删除只会报警告,但是这句指定构建版本的语句会被忽略 
      2.dependencies中 compile 替换为 implementation ,testCompile 替换为 testImplementation ,androidTestCompile 替换为 androidTestImplementation

      dependencies {
          implementation fileTree(dir: 'libs', include: ['*.jar'])
          implementation 'com.android.support:appcompat-v7:27.1.1'
          testImplementation 'junit:junit:4.12'
          androidTestImplementation 'com.android.support.test:runner:1.0.2'
          androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
      }
      
    • 项目根目录下的gradle/wrapper文件夹下的gradle-wrapper.properties文件 
      修改 distributionUrl 的地址

      distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
      
    • 注意:多数教程中都没有提及这个文件,如果不改此处的地址,编译报错

      Gradle DSL method not found: 'google()' Possible causes:  
      The project 'app' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
      

    注意:具体修改内容可用新安装的Android Studio新建一个空白工程作为参照

  • 相关阅读:
    (兼容IE8)的渐变
    左侧固定,右侧自适应,两列等高并且自适应的第二种办法
    左侧定宽,右侧自适应,两列布局且等高
    下拉框重写
    在页面中输出当前客户端时间
    用哈希表去数组重复项,有详细注释
    求数组最大值、求和、乘法表、取整
    类似新浪微博输入字符计数的效果
    将博客搬至CSDN
    Mysql常用操作
  • 原文地址:https://www.cnblogs.com/tc310/p/9179498.html
Copyright © 2011-2022 走看看