1. 程式人生 > >Android Studio 3.0 老專案嵌入教程

Android Studio 3.0 老專案嵌入教程

這裡寫圖片描述

2 修改配置

  • 專案的build.gradle(不是module):

    這裡寫圖片描述

  • 點選gradle-wrapper.properties,修改gradle檔案為4.1。

    這裡寫圖片描述

3 遇到的問題

問題1:error: style attribute ‘@android:attr/windowEnterAnimation’ not found.

解決方案: 在Project/gradle.properties中新增 android.enableAapt2=false
解決方案: 主專案app/build.gradle檔案defaultConfig下新增 flavorDimensions "versionCode"

問題3:Android Profiler遇到沒有辦法框選的問題

這裡寫圖片描述

解決方案:升級sdk版本26及以上版本

問題4:升級sdk到26及以上版本,出現支援庫版本相容問題:all com.android.support libraries must use the exact same version specification(mixing versions can lead to runtime crashes)……

解決方案:主專案app/build.gradle檔案新增如下
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        
def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '27.0.0' } } } }

問題5:升級到3.0,輸入中文時輸入法顯示不全,卡頓情況

解決方案:把AS2.*版本jre替換AS3.0的jre,輸入法正常顯示

問題6:“Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use ‘annotationProcessor’ configuration instead.”

解決方案: 把Project的classpath
‘com.neenbedankt.gradle.plugins:android-apt:1.8’刪除, 同時把Module中apply
plugin: ‘com.neenbedankt.android-apt’的也刪除,
然後把dependencies中原來使用apt的改為annotationProcessor
參考:https://www.2cto.com/kf/201710/692048.html

AS3.0 新功能體驗

參考:http://mp.weixin.qq.com/s/2XmVG4mKEDX6-bvZ0vvmcw