zoukankan      html  css  js  c++  java
  • Android Studio升级到3.0.0后构建项目时出现的问题总结

    如果Android Studio升级到3.0.0,Android Studio会提示你推荐使用3.0.0的构建插件,同时要求Gradle的版本必须是4.1以上。下面是具体的修改步骤:

    1. 修改Gradle的版本,在gradle-wrapper.properties里编辑distributionUrl,如下:

      distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip  //修改为4.1或者更高版本,更多版本详情查看 http://services.gradle.org/distributions/

    2. 在项目顶级build.gradle里,修改构建插件版本为3.0.0,如下:

      buildscript {

          repositories {

            google()  //需要添加这个仓库,去下载3.0.0构建插件

          }

          dependencies {

            classpath 'com.android.tools.build:gradle:3.0.0'

          }

      }

    3. 修改依赖配置

      implementation project(':library')  //将之前的compile改为implementation

      debugImplementation 'com.example.android:app-magic:12.3'  //将之前的debugCompile改为debugImplementation

      //provided改为compileOnly

    4.修改apk输出目录的脚本需要改为类似如下:

      android.applicationVariants.all { variant ->     

        variant.outputs.all { output->  //把each改为all       

          outputFileName = "${variant.name}-${variant.versionName}.apk"  //把output.outputFile改为outputFileName     

        }   

      }

    5. android-apt修改为annotationProcessor,如下:

        1)//classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'  //去掉顶级build.gradle下的android-apt依赖

        2)//apply plugin: 'android-apt'      

          //apt { arguments { } }  //去掉项目build.gradle里的apt加载和设置

        3)添加依赖

            dependencies{  //这里是androidannotations4.1.0的依赖           

                implementation "org.androidannotations:androidannotations-api:4.1.0"           

                annotationProcessor "org.androidannotations:androidannotations:4.1.0"         

            }

            dependencies {  //这里是dagger2.0的依赖            

                compile 'com.google.dagger:dagger:2.0'            

                annotationProcessor 'com.google.dagger:dagger-compiler:2.0'         

            }

        4.annotationProcessor添加到编译路径

            android {           

               defaultConfig {             

                   javaCompileOptions {               

                      annotationProcessorOptions {                 

                        includeCompileClasspath true

                         //还可以添加参数,比如arguments = [ foo : 'bar' ]
                      }

                   }             }          }

    6. multidex的配置,如下: 

        //MultiDex.install(this); //去掉,同时去掉 'com.android.support:multidex:1.0.1' 依赖

        defaultConfig{   //直接启用multiDexEnabled true 即可
            multiDexEnabled true
        }

     

  • 相关阅读:
    vim编辑器经常使用命令
    @RequestMapping value 能够反复吗 [
    [Android 4.4.2] 泛泰A870 Mokee4.4.2 20140531 RC1.0 by syhost
    leetcode——Reverse Linked List II 选择链表中部分节点逆序(AC)
    烤羊肉串引来的思考——命令模式
    全面解析Activity的生命周期
    PHP与Linux进程间的通信
    模块管理常规功能自己定义系统的设计与实现(36--终级阶段 综合查询[3])
    小米与格力的10亿豪赌!
    《Java设计模式》之装饰模式
  • 原文地址:https://www.cnblogs.com/yongfengnice/p/7744397.html
Copyright © 2011-2022 走看看