Android Studio項(xiàng)目適配AndroidX(Android 9.0)的方法步驟
說(shuō)在前面:
老項(xiàng)目、大項(xiàng)目適配Android X 注意了,一定要謹(jǐn)慎、謹(jǐn)慎、再謹(jǐn)慎。項(xiàng)目中用到的第三方庫(kù)多的話會(huì)很麻煩,有些第三方庫(kù)還沒(méi)有適配Android X。
適配Android X的兩種情況:一種是老項(xiàng)目適配Android X ,另外一種是新項(xiàng)目要求適配Android 9.0
硬核要求
Android studio 版本升級(jí)到3.2.0 以上的版本,
distributionUrl的版本升級(jí)為 4.10.1以上
targetSdkVersion 28
gradle 插件的版本升級(jí)為 3.2.0以上
classpath 'com.android.tools.build:gradle:3.2.0'
這里以AS 3.4為例
第一步:
新項(xiàng)目,這步可以跳過(guò)。
compileSdkVersion 28 defaultConfig { applicationId "gangqing.pu.xmxidaq" minSdkVersion 19 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }
第二步:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.0' classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url "https://jitpack.io" } } } task clean(type: Delete) { delete rootProject.buildDir }
第三步:
在gradle.properties 中加入如下代碼,表示支持Android X
android.useAndroidX=true android.enableJetifier=true
第四步:
Android Studio ----> Refactor----> Migrate to androidx,,一鍵轉(zhuǎn)為 androidX
第五步:
支持Java 1.8
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
第六步:
修改布局,比如:ConstraintLayout
變化之前 | AndroidX |
---|---|
<android.support.constraint.ConstraintLayout | <androidx.constraintlayout.widget.ConstraintLayout |
注意:如果是老項(xiàng)目適配AndroidX,沒(méi)有找到ConstraintLayout 的話,那么還需要在中添加如下代碼
dependencies { implementation 'androidx.constraintlayout:constraintlayout:1.1.3' }
第四步之后,
<android.support.constraint.ConstraintLayout
變?yōu)?lt;androidx.constraintlayout.ConstraintLayout 這時(shí)你需要修改為
<androidx.constraintlayout.widget.ConstraintLayout |
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。
上一篇:Android使用美團(tuán)多渠道打包方案詳解
欄 目:Android
下一篇:Android實(shí)現(xiàn)折線走勢(shì)圖
本文標(biāo)題:Android Studio項(xiàng)目適配AndroidX(Android 9.0)的方法步驟
本文地址:http://mengdiqiu.com.cn/a1/Android/9066.html
您可能感興趣的文章
- 01-10Android自定義View之繪制圓形頭像功能
- 01-10Android實(shí)現(xiàn)雙擊返回鍵退出應(yīng)用實(shí)現(xiàn)方法詳解
- 01-10android實(shí)現(xiàn)記住用戶名和密碼以及自動(dòng)登錄
- 01-10android實(shí)現(xiàn)簡(jiǎn)單計(jì)算器功能
- 01-10Android 友盟第三方登錄與分享的實(shí)現(xiàn)代碼
- 01-10android實(shí)現(xiàn)指紋識(shí)別功能
- 01-10Emoji表情在Android JNI中的兼容性問(wèn)題詳解
- 01-10Android實(shí)現(xiàn)圓形漸變加載進(jìn)度條
- 01-10android開(kāi)發(fā)環(huán)境中SDK文件夾下的所需內(nèi)容詳解
- 01-10android異步消息機(jī)制 源碼層面徹底解析(1)


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10Android自定義View之繪制圓形頭像功能
- 01-10Android實(shí)現(xiàn)雙擊返回鍵退出應(yīng)用實(shí)現(xiàn)方
- 01-10android實(shí)現(xiàn)簡(jiǎn)單計(jì)算器功能
- 01-10android實(shí)現(xiàn)記住用戶名和密碼以及自動(dòng)
- 01-10C++自定義API函數(shù)實(shí)現(xiàn)大數(shù)相乘算法
- 01-10Android 友盟第三方登錄與分享的實(shí)現(xiàn)代
- 01-10android實(shí)現(xiàn)指紋識(shí)別功能
- 01-10如何給Flutter界面切換實(shí)現(xiàn)點(diǎn)特效
- 01-10Android實(shí)現(xiàn)圓形漸變加載進(jìn)度條
- 01-10Emoji表情在Android JNI中的兼容性問(wèn)題詳
隨機(jī)閱讀
- 01-11Mac OSX 打開(kāi)原生自帶讀寫NTFS功能(圖文
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
- 04-02jquery與jsp,用jquery
- 01-10delphi制作wav文件的方法
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 01-10C#中split用法實(shí)例總結(jié)
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什