欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android Studio項(xiàng)目適配AndroidX(Android 9.0)的方法步驟

 更新時(shí)間:2019年11月26日 11:33:27   作者:小紅妹  
這篇文章主要介紹了Android Studio項(xiàng)目適配AndroidX(Android 9.0)的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

說在前面:

老項(xiàng)目、大項(xiàng)目適配Android X 注意了,一定要謹(jǐn)慎、謹(jǐn)慎、再謹(jǐn)慎。項(xiàng)目中用到的第三方庫多的話會很麻煩,有些第三方庫還沒有適配Android X。

適配Android X的兩種情況:一種是老項(xiàng)目適配Android X ,另外一種是新項(xiàng)目要求適配Android 9.0

硬核要求

Android studio 版本升級到3.2.0 以上的版本,
distributionUrl的版本升級為 4.10.1以上
targetSdkVersion 28
gradle 插件的版本升級為 3.2.0以上

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

這里以AS 3.4為例

在這里插入圖片描述

第一步:

新項(xiàng)目,這步可以跳過。

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,沒有找到ConstraintLayout 的話,那么還需要在在這里插入圖片描述中添加如下代碼

dependencies {
   implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

第四步之后,
<android.support.constraint.ConstraintLayout
變?yōu)?lt;androidx.constraintlayout.ConstraintLayout 這時(shí)你需要修改為
<androidx.constraintlayout.widget.ConstraintLayout |

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android編程之通知欄的用法小結(jié)

    Android編程之通知欄的用法小結(jié)

    這篇文章主要介紹了Android編程之通知欄的用法,結(jié)合實(shí)例形式總結(jié)分析了Android通知欄的相關(guān)操作技巧,包括發(fā)送、刪除通知、自定義布局等操作實(shí)現(xiàn)方法,需要的朋友可以參考下
    2017-01-01
  • Android如何自定義升級對話框示例詳解

    Android如何自定義升級對話框示例詳解

    對話框是我們在平時(shí)經(jīng)常會遇到的一個(gè)功能,但自帶的對話框不夠美觀,大家一般都會自定義,下面這篇文章主要給大家介紹了關(guān)于Android如何自定義升級對話框的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-08-08
  • Android仿微信錄制小視頻

    Android仿微信錄制小視頻

    這篇文章主要為大家詳細(xì)介紹了Android仿微信錄制小視頻,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android ViewPager實(shí)現(xiàn)選項(xiàng)卡切換

    Android ViewPager實(shí)現(xiàn)選項(xiàng)卡切換

    這篇文章主要介紹了Android ViewPager實(shí)現(xiàn)選項(xiàng)卡切換,詳細(xì)分析了ViewPager實(shí)現(xiàn)選項(xiàng)卡切換功能,感興趣的小伙伴們可以參考一下
    2016-02-02
  • 深入分析安卓(Android)中的注解

    深入分析安卓(Android)中的注解

    注解是我們經(jīng)常接觸的技術(shù),Java有注解,Android也有注解,本文將試圖介紹Android中的注解,以及ButterKnife和Otto這些基于注解的庫的一些工作原理.下面一起來看看。
    2016-08-08
  • 如何解決android Toast重復(fù)顯示

    如何解決android Toast重復(fù)顯示

    Toast是一種簡易的消息提示框,它無法獲取焦點(diǎn),按設(shè)置的時(shí)間來顯示完以后會自動消失,一般用于幫助或提示,本文給大家介紹android Toast重復(fù)顯示的解決辦法,涉及到android toast 相關(guān)知識,有需要的朋友參考下
    2016-01-01
  • Android 進(jìn)度條按鈕ProgressButton的實(shí)現(xiàn)代碼

    Android 進(jìn)度條按鈕ProgressButton的實(shí)現(xiàn)代碼

    這篇文章主要介紹了Android 進(jìn)度條按鈕實(shí)現(xiàn)(ProgressButton)代碼,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下
    2018-10-10
  • 解決Android 10/Android Q手機(jī)在后臺無法正常定位問題

    解決Android 10/Android Q手機(jī)在后臺無法正常定位問題

    這篇文章主要介紹了解決Android 10/Android Q手機(jī)在后臺無法正常定位問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • Android 判斷ip地址合法實(shí)現(xiàn)代碼

    Android 判斷ip地址合法實(shí)現(xiàn)代碼

    這篇文章主要介紹了Android 判斷ip地址合法實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • 詳解android在mob平臺實(shí)現(xiàn)qq登陸和分享

    詳解android在mob平臺實(shí)現(xiàn)qq登陸和分享

    這篇文章主要介紹了詳解android在mob平臺實(shí)現(xiàn)qq登陸和分享,對接入第三方平臺SDK感興趣的同學(xué)們,可以參考下
    2021-04-04

最新評論