《第一行代码》添加百分比布局库依赖问题

错误条件

按照《第一行代码》中操作,给app模块添加依赖:compile ‘com.android.support.percent:24.2.1‘,gradle同步的时候报出以下错误:

ERROR: Failed to resolve: com.android.support.percent:24.2.1:
Affected Modules: app

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: app

解决过程

后上网查阅,发现两个错误:

  1. 我的Android Studio的版本是3.4.1(可以通过菜单栏Help-About查看),Android studio升级到3.0之后,compile就改为了implementation
  2. SDK版本是29(在app模块的build.gradle中指明),依赖的版本24.2.1 应该改为和sdk版本对应的版本29.0.0

于是就将百分比布局的依赖改成了:implementation ‘com.android.support.percent:29.0.0‘, 再次同步,依然报错:

ERROR: Failed to resolve: com.android.support.percent:24.2.1:
Affected Modules: app

再次百度,发现了一件事:Androidx库和Android.support库不能共存,而我其它的依赖都用的是Androidx库,如下:

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

那么我的问题就转化成了:找到percentLayout依赖在androidx库中的写法,得到的结果是androidx.percentlayout:percentlayout:1.0.0,再次同步,成功!

最终解决办法

依赖的写法改为:implement ‘androidx.percentlayout:percentlayout:1.0.0‘



以下附上Androidx的映射表,方便以后查看

android.arch.core:common
androidx.arch.core:core-common:2.0.0-rc01

android.arch.core:core
androidx.arch.core:core:2.0.0-rc01

android.arch.core:core-testing
androidx.arch.core:core-testing:2.0.0-rc01

android.arch.core:runtime
androidx.arch.core:core-runtime:2.0.0-rc01

android.arch.lifecycle:common
androidx.lifecycle:lifecycle-common:2.0.0-rc01

android.arch.lifecycle:common-java8
androidx.lifecycle:lifecycle-common-java8:2.0.0-rc01

android.arch.lifecycle:compiler
androidx.lifecycle:lifecycle-compiler:2.0.0-rc01

android.arch.lifecycle:extensions
androidx.lifecycle:lifecycle-extensions:2.0.0-rc01

android.arch.lifecycle:livedata
androidx.lifecycle:lifecycle-livedata:2.0.0-rc01

android.arch.lifecycle:livedata-core
androidx.lifecycle:lifecycle-livedata-core:2.0.0-rc01

android.arch.lifecycle:reactivestreams
androidx.lifecycle:lifecycle-reactivestreams:2.0.0-rc01

android.arch.lifecycle:runtime
androidx.lifecycle:lifecycle-runtime:2.0.0-rc01

android.arch.lifecycle:viewmodel
androidx.lifecycle:lifecycle-viewmodel:2.0.0-rc01

android.arch.paging:common
androidx.paging:paging-common:2.0.0-rc01

android.arch.paging:runtime
androidx.paging:paging-runtime:2.0.0-rc01

android.arch.paging:rxjava2
androidx.paging:paging-rxjava2:2.0.0-rc01

android.arch.persistence.room:common
androidx.room:room-common:2.0.0-rc01

android.arch.persistence.room:compiler
androidx.room:room-compiler:2.0.0-rc01

android.arch.persistence.room:guava
androidx.room:room-guava:2.0.0-rc01

android.arch.persistence.room:migration
androidx.room:room-migration:2.0.0-rc01

android.arch.persistence.room:runtime
androidx.room:room-runtime:2.0.0-rc01

android.arch.persistence.room:rxjava2
androidx.room:room-rxjava2:2.0.0-rc01

android.arch.persistence.room:testing
androidx.room:room-testing:2.0.0-rc01

android.arch.persistence:db
androidx.sqlite:sqlite:2.0.0-rc01

android.arch.persistence:db-framework
androidx.sqlite:sqlite-framework:2.0.0-rc01

com.android.support.constraint:constraint-layout
androidx.constraintlayout:constraintlayout:1.1.2

com.android.support.constraint:constraint-layout-solver
androidx.constraintlayout:constraintlayout-solver:1.1.2

com.android.support.test.espresso.idling:idling-concurrent
androidx.test.espresso.idling:idling-concurrent:3.1.0

com.android.support.test.espresso.idling:idling-net
androidx.test.espresso.idling:idling-net:3.1.0

com.android.support.test.espresso:espresso-accessibility
androidx.test.espresso:espresso-accessibility:3.1.0

com.android.support.test.espresso:espresso-contrib
androidx.test.espresso:espresso-contrib:3.1.0

com.android.support.test.espresso:espresso-core
androidx.test.espresso:espresso-core:3.1.0

com.android.support.test.espresso:espresso-idling-resource
androidx.test.espresso:espresso-idling-resource:3.1.0

com.android.support.test.espresso:espresso-intents
androidx.test.espresso:espresso-intents:3.1.0

com.android.support.test.espresso:espresso-remote
androidx.test.espresso:espresso-remote:3.1.0

com.android.support.test.espresso:espresso-web
androidx.test.espresso:espresso-web:3.1.0

com.android.support.test.janktesthelper:janktesthelper
androidx.test.jank:janktesthelper:1.0.1

com.android.support.test.services:test-services
androidx.test:test-services:1.1.0

com.android.support.test.uiautomator:uiautomator
androidx.test.uiautomator:uiautomator:2.2.0

com.android.support.test:monitor
androidx.test:monitor:1.1.0

com.android.support.test:orchestrator
androidx.test:orchestrator:1.1.0

com.android.support.test:rules
androidx.test:rules:1.1.0

com.android.support.test:runner
androidx.test:runner:1.1.0

com.android.support:animated-vector-drawable
androidx.vectordrawable:vectordrawable-animated:1.0.0

com.android.support:appcompat-v7
androidx.appcompat:appcompat:1.0.0

com.android.support:asynclayoutinflater
androidx.asynclayoutinflater:asynclayoutinflater:1.0.0

com.android.support:car
androidx.car:car:1.0.0-alpha5

com.android.support:cardview-v7
androidx.cardview:cardview:1.0.0

com.android.support:collections
androidx.collection:collection:1.0.0

com.android.support:coordinatorlayout
androidx.coordinatorlayout:coordinatorlayout:1.0.0

com.android.support:cursoradapter
androidx.cursoradapter:cursoradapter:1.0.0

com.android.support:customtabs
androidx.browser:browser:1.0.0

com.android.support:customview
androidx.customview:customview:1.0.0

com.android.support:design
com.google.android.material:material:1.0.0-rc01

com.android.support:documentfile
androidx.documentfile:documentfile:1.0.0

com.android.support:drawerlayout
androidx.drawerlayout:drawerlayout:1.0.0

com.android.support:exifinterface
androidx.exifinterface:exifinterface:1.0.0

com.android.support:gridlayout-v7
androidx.gridlayout:gridlayout:1.0.0

com.android.support:heifwriter
androidx.heifwriter:heifwriter:1.0.0

com.android.support:interpolator
androidx.interpolator:interpolator:1.0.0

com.android.support:leanback-v17
androidx.leanback:leanback:1.0.0

com.android.support:loader
androidx.loader:loader:1.0.0

com.android.support:localbroadcastmanager
androidx.localbroadcastmanager:localbroadcastmanager:1.0.0

com.android.support:media2
androidx.media2:media2:1.0.0-alpha03

com.android.support:media2-exoplayer
androidx.media2:media2-exoplayer:1.0.0-alpha01

com.android.support:mediarouter-v7
androidx.mediarouter:mediarouter:1.0.0

com.android.support:multidex
androidx.multidex:multidex:2.0.0

com.android.support:multidex-instrumentation
androidx.multidex:multidex-instrumentation:2.0.0

com.android.support:palette-v7
androidx.palette:palette:1.0.0

com.android.support:percent
androidx.percentlayout:percentlayout:1.0.0

com.android.support:preference-leanback-v17
androidx.leanback:leanback-preference:1.0.0

com.android.support:preference-v14
androidx.legacy:legacy-preference-v14:1.0.0

com.android.support:preference-v7
androidx.preference:preference:1.0.0

com.android.support:print
androidx.print:print:1.0.0

com.android.support:recommendation
androidx.recommendation:recommendation:1.0.0

com.android.support:recyclerview-selection
androidx.recyclerview:recyclerview-selection:1.0.0

com.android.support:recyclerview-v7
androidx.recyclerview:recyclerview:1.0.0

com.android.support:slices-builders
androidx.slice:slice-builders:1.0.0

com.android.support:slices-core
androidx.slice:slice-core:1.0.0

com.android.support:slices-view
androidx.slice:slice-view:1.0.0

com.android.support:slidingpanelayout
androidx.slidingpanelayout:slidingpanelayout:1.0.0

com.android.support:support-annotations
androidx.annotation:annotation:1.0.0

com.android.support:support-compat
androidx.core:core:1.0.0

com.android.support:support-content
androidx.contentpager:contentpager:1.0.0

com.android.support:support-core-ui
androidx.legacy:legacy-support-core-ui:1.0.0

com.android.support:support-core-utils
androidx.legacy:legacy-support-core-utils:1.0.0

com.android.support:support-dynamic-animation
androidx.dynamicanimation:dynamicanimation:1.0.0

com.android.support:support-emoji
androidx.emoji:emoji:1.0.0

com.android.support:support-emoji-appcompat
androidx.emoji:emoji-appcompat:1.0.0

com.android.support:support-emoji-bundled
androidx.emoji:emoji-bundled:1.0.0

com.android.support:support-fragment
androidx.fragment:fragment:1.0.0

com.android.support:support-media-compat
androidx.media:media:1.0.0

com.android.support:support-tv-provider
androidx.tvprovider:tvprovider:1.0.0

com.android.support:support-v13
androidx.legacy:legacy-support-v13:1.0.0

com.android.support:support-v4
androidx.legacy:legacy-support-v4:1.0.0

com.android.support:support-vector-drawable
androidx.vectordrawable:vectordrawable:1.0.0

com.android.support:swiperefreshlayout
androidx.swiperefreshlayout:swiperefreshlayout:1.0.0

com.android.support:textclassifier
androidx.textclassifier:textclassifier:1.0.0

com.android.support:transition
androidx.transition:transition:1.0.0

com.android.support:versionedparcelable
androidx.versionedparcelable:versionedparcelable:1.0.0

com.android.support:viewpager
androidx.viewpager:viewpager:1.0.0

com.android.support:wear
androidx.wear:wear:1.0.0

com.android.support:webkit
androidx.webkit:webkit:1.0.0


参考文献请点击:这里

原文地址:https://www.cnblogs.com/skye-you/p/11334019.html

时间: 2024-11-10 11:28:57

《第一行代码》添加百分比布局库依赖问题的相关文章

第一行代码中的添加百分比布局库依赖问题

找到android SDK的文件夹I:\AndroidSDk\extras\android\m2repository\com\android\support\percent在这里就能看到各种版本的,这里我选择26的26.0.0-alpha1,重新导入,之后重新Sync就可以了! dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.

Android添加百分比布局库时显示Failed to resolve: com.android.support.percent:问题

这是看第一行代码中遇到的问题,要添加百分比布局库的依赖时要在app下的bulid.gradle添加以下代码 implementation fileTree(dir:'libs',include:['*.jar'])implementation 'com.android.support:appcompat-v7:28.0.0'implementation 'com.android.support:percent:28.0.0' testCompile 'junit:junit:4.12' 注意这一

第一行代码 - 布局

基本布局 线性布局:LinearLayout android:orientation:指定排列的方向,参数:vertical/horizontal.不指定时,默认的排列方向是horizontal. android:layout_gravity:指定控件在布局的对齐方式.可以用"|"分割,同时指定多个参数. 注意: 排列方向为horizontal时,内部控件不能将宽度指定为match_parent.vertical同理. 排列方向为horizontal时,只有垂直方向上的对齐方式才会生效

Android 百分比布局库扩展 为了适配而改写

转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/46767825: 本文出自:[张鸿洋的博客] 一 概述 上周一我们发布了Android 百分比布局库(percent-support-lib) 解析与扩展中对percent-support这个库进行了解析和添加了PercentLinearLayout的支持. 那么为什么本篇博客的存在的意义是什么呢? 首先我们回顾下百分比布局库的用法,提供了PercentRelativeLayo

20172327 2017-2018-2 《第一行代码Android》第一章学习总结

学号 2017-2018-2 <第一行代码Android>第一章学习总结 教材学习内容总结 - Android系统架构: 1.Linux内核层 Android系统是基于Linux内核的,这一层为Android设备的各种硬件提供了底层的驱动,如显示驱动,音频驱动,照相机驱动,蓝牙驱动,Wi-Fi驱动,电源管理等. 2.系统运行底层 - 通过一些C/C++库来为Android系统提供了主要的特性支持 库名 功能 SQLite库 提供数据库的支持 OpenGL/ES库 提供3D绘图支持 Webkit

Android第一行代码之制作简易版新闻应用

我是跟着<Android第一行代码>写代码的,想写个博来加深印象一点 一.添加依赖库RecyclerView 在app下的build.gradle中的dependencies添加一句:(添加后要sync now) implementation 'androidx.recyclerview:recyclerview:1.0.0' 二.新建一个新闻类News.java 1 public class News { 2 private String title;//新闻标题 3 private Str

HTML5&CSS3初学者指南(1) – 编写第一行代码

介绍 网络时代已经到来.现在对人们来说,每天上网冲浪已经成为一种最为常见的行为. 在网页浏览器中输入一段文本地址,就像http://www.codeproject.com,等待一下,网页就加载到浏览器窗口中.一个典型的网页是由文本.图像和链接组成的.除去内容上的差异,不同网站的网页也具有不同的外观和感受,以实现在网络上建立自己的身份品牌的目的. 如果你也曾想要了解你屏幕上的这些网页是如何被创建出并以各式各样的方式渲染的,那么这里正是你可以了解到这些知识的地方.让我们一起走进在浏览器中创建了这么多

Android 屏幕适配(二)增强版百分比布局库(percent-support-lib)

转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/46767825: 本文出自:[张鸿洋的博客] 一 概述 上周一我们发布了Android 百分比布局库(percent-support-lib) 解析与扩展中对percent-support这个库进行了解析和添加了PercentLinearLayout的支持. 那么为什么本篇博客的存在的意义是什么呢? 首先我们回顾下百分比布局库的用法,提供了PercentRelativeLayo

第一行代码

今天看打了一篇推荐<第一行代码 Android>(郭霖),是郭大神的, Android:一 简介 框架 已发布的版本 应用特色 开发环境 程序结构 Logcat工具 二 Activity 什么是活动 活动用法 intent与其用法 生命周期:onCreate() onStart() onPause() onStop() onDestory() onRestart() 活动启动模式:standard singleTop singleTask singleInstance 活动集合三 UI控件 常