Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'java.lang.String' is deprecated in Android

I have write simple TAG like this:

private static final String TAG = "MainActivity"; 

String is deprecated

IDE screenshot showing strikethrough through String

Is there any alternative way available to use String?

like image 502
Yagnesh Lashkari Avatar asked May 31 '19 12:05

Yagnesh Lashkari


People also ask

Is Java deprecated in Android?

To conclude (and to answer my own question), no, Java will probably stay as the main language for Android programming for a long time. But this doesn't mean Google is not looking for other options to develop in parallel to step away from Java.

Can I use deprecated methods in Android?

Yes you can use deprecated methods as long as the depreciated method exists in the framework. By deprecating a method the platform developers are trying to tell you that either something is wrong with the method or there is already better way for doing the task.

What does deprecated mean in Android?

An element may be deprecated for any of several reasons, for example, its usage is likely to lead to errors; it may be changed incompatibly or removed in a future version; it has been superseded by a newer, usually preferable alternative; or it is obsolete.

Is Android XML deprecated?

Short answer: Not possible. @deprecated tags are used by the Android source inside comments as it can be seen in fw/base core/res/values/attrs. xml (see line 3427 for autoText as referred to in the original post), in fw/base core/res/values/public.


1 Answers

As per comment in this java-lang-string-is-deprecated-in-android-studio question,

Remove folder .AndroidStudioX.X in your User folder and Restart IDE.

NOTE: AndroidStudioX.X means if you are using Android Studio version 3.4 then .AndroidStudio3.4 will be there.

Path will be like Windows : C:\Users\<PCNAME>\.AndroidStudio3.4

Linux/Ubuntu : /home/yourname/.AndroidStudio3.4

Hope it will be helpful to you.

like image 186
Pratik Butani Avatar answered Oct 02 '22 04:10

Pratik Butani