简体   繁体   English

为什么这个旧依赖会使我的 gradle 崩溃?

[英]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:我的问题是:

  1. Where should i add this line???我应该在哪里添加这一行??? I couldn't find any clear unstructions of this simple action...我找不到这个简单动作的任何明确说明......
  2. Why do i still get this error?为什么我仍然收到此错误? I removed this package a long time ago.我很久以前删除了这个 package。 I cleaned my platforms and i can't find any trace for it in my project?我清理了我的平台,但在我的项目中找不到任何痕迹? How to i get rid of it?我该如何摆脱它?

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:我认为您可以通过两种主要方式做到这一点:

  1. 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.这个来自不同问题的答案解释了这个过程。

  2. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM