[英]Why does this old dependency crashes my gradle?
A long time ago i installed a package which gives me the height of the keyboard on an android device.很久以前,我安装了 package,它给了我 android 设备上键盘的高度。 Eventually the package didn't served well my purpose so i uninstalled it.
最终 package 并没有很好地满足我的目的,所以我卸载了它。 A few days ago i tried to build my app but i got the following error:
几天前,我尝试构建我的应用程序,但出现以下错误:
Build file 'C:\Users\odedo\Documents\GitHub\tripper\app\platforms\android\app\build.gradle' line: 598
A problem occurred configuring project ':app'.
Could not GET 'https://dl.bintray.com/crysis21/Android/com/hold1/keyboardheightprovider/0.0.9/keyboardheightprovider-0.0.9.pom'. Received status code 403 from server: Forbidden
Command gradlew.bat failed with exit code 1
Apparently the package is no longer available and i should add this dependency to my code:显然 package 不再可用,我应该将此依赖项添加到我的代码中:
implementation 'ro.holdone:keyboardHeightProvider:1.0.3'
My questions are:我的问题是:
Here is the NPM: https://github.com/Crysis21/KeyboardHeightProvider And here is the same question asked here on Stack overflow which didn't helped at all: implementation 'com.hold1:keyboardheightprovider:0.0.9'这是 NPM: https://github.com/Crysis21/KeyboardHeightProvider这里是关于堆栈溢出的同一个问题,它根本没有帮助: implementation 'com.hold1:keyboardheightprovider:0.0.9'
I am desperate for a solution... Please help我迫切需要一个解决方案...请帮助
I left a question for you as a comment above for clarifications, but generally dependencies are added to the build.gradle
files;我在上面的评论中留下了一个问题供您澄清,但通常将依赖项添加到
build.gradle
文件中; either at the project- or app-level.在项目或应用程序级别。
I would assume you need to add this dependency at the application-level Gradle file, as it is more usual, so look for the dependencies
portion of the build.gradle
file (usually at the bottom) and add it as such:我假设您需要在应用程序级别的 Gradle 文件中添加此依赖项,因为它更常见,因此请查找
build.gradle
文件的dependencies
项部分(通常在底部)并按如下方式添加:
android {
...
}
dependencies {
...
implementation 'ro.holdone:keyboardHeightProvider:1.0.3'
}
UPDATE: As an alternative, I would recommend you simply move away from 3rd-party libraries that help you do or find things that Android already provides.更新:作为替代方案,我建议您远离帮助您完成或查找 Android 已经提供的东西的第三方库。 There's two main ways I can think you can do this:
我认为您可以通过两种主要方式做到这一点:
You can implement a GlobalLayoutListener
to figure out the total size of the application's layout, and from there deduce the total size that the soft-keyboard is occupying.您可以实现一个
GlobalLayoutListener
来计算应用程序布局的总大小,并从中推断出软键盘占用的总大小。 This answer from a different question sort of explains this process.这个来自不同问题的答案解释了这个过程。
The second way you can find out the size of your keyboard is mentioned in the link you shared above , and is by leveraging Android's WindowInsets
APIs from androidx
to get exact measurements you're looking for.您可以在上面共享的链接中提到第二种查找键盘大小的方法,它是利用
androidx
的 Android WindowInsets
API 来获得您正在寻找的精确测量值。 I believe this solution may only be available for higher Android version, so choose your weapons wisely!我相信这个解决方案可能只适用于更高版本的Android,所以请明智地选择你的武器!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.