欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android studio 2 版本升级 Android studio 3 版本注意事项

程序员文章站 2022-05-03 11:53:07
1. compile 需要改成 implementation 或者 api例:implementation 'com.android.support:support-v4:23.4.0'详细规则 https://blog.csdn.net/yuzhiqiang_1993/article/detail ......

 

1. compile 需要改成 implementation 或者 api
例:implementation 'com.android.support:support-v4:23.4.0'
详细规则 https://blog.csdn.net/yuzhiqiang_1993/article/details/78366985

2. apt 需要去掉,改成 annotationprocessor
例:annotationprocessor 'org.greenrobot:eventbus-annotation-processor:3.0.1'

3. 多渠道需要这样配置:

例:
defaultconfig {
  applicationid "com.roadrover.bluetooth"
  minsdkversion 23
  targetsdkversion 25
  versionname "2.1.4"
  versioncode 214

  flavordimensions "color" // 添加
}
productflavors {
  t3plus {
    dimension "color" // 添加
  }
  imx6 {
    dimension "color" // 添加
  }
  imx6_yutong17a { 
    dimension "color" // 添加
  }
}

 

4. ndk暂时不要升级最新版本,会影响编译


5. could not find com.android.tools.lint:lint-gradle:xxxx : allprojects模块的repositories中缺少了google()

例:allprojects {
    repositories {
      jcenter()
      google()
    }
  }

 


6. error: style attribute ‘@android:attr/windowenteranimation’ not found.

修改前
<style name="remnote_play_time_animation">
  <item name="@android:windowenteranimation">@anim/remote_play_popup_show</item>
  <item name="@android:windowexitanimation">@anim/remote_play_popup_hide</item>
</style>
修改后
<style name="remnote_play_time_animation">
  <item name="android:windowenteranimation">@anim/remote_play_popup_show</item>
  <item name="android:windowexitanimation">@anim/remote_play_popup_hide</item>
</style>

 

7.sdk工具版本
app中的gradle中的
  compilesdkversion 27
  buildtoolsversion '27.0.3'
gradle中的wrapper中的distributionurl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
project中的gradle的classpath 'com.android.tools.build:gradle:3.1.2'

 

8.eventbus异常

defaultconfig {
  minsdkversion 9
  targetsdkversion 19

  javacompileoptions { // 添加
    annotationprocessoroptions {
    arguments = [eventbusindex: "com.example.myapp.myeventbusindex"]
    }
  }
}
dependencies {
  api 'com.android.support:support-v4:27.0.0'
  api 'org.greenrobot:eventbus:3.1.1' // 添加
  annotationprocessor 'org.greenrobot:eventbus-annotation-processor:3.1.1' // 添加
}

 


9.修改aar文件名字的异常

修改前
libraryvariants.all { variant ->
  variant.outputs.each { output ->
    def outputfile = output.outputfile
    if (outputfile != null && outputfile.name.endswith('.aar')) {
      def filename = "libvlc.aar"
      output.outputfile = new file(outputfile.parent, filename)
    }
  }
}
修改后
libraryvariants.all { variant ->
  variant.outputs.all { output -> // 修改后
    def outputfile = output.outputfile
    if (outputfile != null && outputfile.name.endswith('.aar')) {
      def filename = "libvlc.aar"
      outputfilename = new file("../../../release/", filename) // 修改后
    }
  }
}

 

10.android sdk platform-tools 版本使用26.0.2

上一篇: JavaScript 基础

下一篇: ES6迭代器