27

KeyboardView has been deprecated official by android team in API level 29 and i didn't able to find the alternative way for this. Please let me know if there any alternative?

Suraj Bahadur
  • 3,730
  • 3
  • 27
  • 55

1 Answers1

10

The only solution Google suggests is copying KeyboardView.java and Keyboard.java files to your local project from Android AOSP. With some customization I managed to make it work as old deprecated KeyboardView and Keyboard Android's classes.

You will also have your local copy of com.android.internal.R attributes (stylable) from from here

You can notice, it is annotated as

<!-- {@deprecated Copy this definition into your own application project.} -->

Google:

This class was deprecated in API level 29. This class is deprecated because this is just a convenient UI widget class that application developers can re-implement on top of existing public APIs. If you have already depended on this class, consider copying the implementation from AOSP into your project or re-implementing a similar widget by yourselves

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
  • 1
    Keyboard.java has **deprecated** annotation -.- this is the correct [link](https://android.googlesource.com/platform/frameworks/base.git/+/b798689749c64baba81f02e10cf2157c747d6b46/core/java/android/inputmethodservice/Keyboard.java) – isthemartin Sep 02 '20 at 15:46
  • 1
    @isthemartin Yes, and as I stated in my answer, you should copy the deprecated class and make minor changes. One of such change is remove the deprecated annotation. The class itself works well. It is what Google suggests – Misha Akopov Sep 02 '20 at 16:04
  • 2
    is right, so I have one more question: what happen with **com.android.internal.R** ? it seems that cannot be found on my project – isthemartin Sep 02 '20 at 16:07
  • @isthemartin You also need to copy it from Android Open Source. See my updated answer – Misha Akopov Sep 02 '20 at 16:19
  • 1
    By following your answer, I'm facing an error as "Error inflating class com.android.urdu.KeyboardView". Why I'm getting this error? – Nabeel Ahmed Feb 17 '21 at 07:57
  • 1
    please take a look here https://stackoverflow.com/q/66239268/12050970. I'm facing this issue. – Nabeel Ahmed Feb 17 '21 at 09:47
  • @NabeelAhmed Did you resolve the issue?? – Vijayadhas Chandrasekaran Jan 25 '22 at 09:13
  • Thank you! Could you please tell where to find com.android.internal.R.id.keyboardView and com.android.internal.R.id.button_close? – Svetlana Rozhkova Feb 11 '22 at 14:47
  • 1
    How can we keep recyclerview as the keyboard view instead of the keypad, do anyone aware of that ? – Aan Jul 06 '22 at 16:11