Find deprecated Android APIs
org.openrewrite.kotlin.android.FindDeprecatedAndroidApis$KtRecipeio.moderne.recipe:recipes-kotlinSearch-only bundle that flags Android APIs the platform has deprecated or removed: findViewById, AsyncTask, the single-arg getColor/getDrawable/getColorStateList resource getters, the zero-arg Handler() constructor, kotlinx.android.synthetic imports, the moved kotlinx.android.parcel.Parcelize import, startActivityForResult/onActivityResult/requestPermissions, LocalBroadcastManager, deprecated Fragment lifecycle methods, Resources.getDrawable / getColor, startService, PreferenceManager, Vibrator.vibrate(long), Context.registerReceiver without flags, and MutableLiveData allocations.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.kotlin.android.FindDeprecatedAndroidApis$KtRecipeIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:recipes-kotlin:0.2.0Definition
This recipe runs the following recipes in order.
- Find
findViewByIdcall sitesorg.openrewrite.kotlin.android.FindFindViewById$KtRecipe - Find
AsyncTaskinstantiationsorg.openrewrite.kotlin.android.FindAsyncTask$KtRecipe - Find
AsyncTask.execute/executeOnExecutorcallsorg.openrewrite.kotlin.android.FindAsyncTaskExecute$KtRecipe - Find deprecated
Context.getColor/getDrawable/getColorStateListcallsorg.openrewrite.kotlin.android.FindDeprecatedResourceGetters$KtRecipe - Find
resources.getDrawable(...)(one-arg) callsorg.openrewrite.kotlin.android.FindResourcesGetDrawable$KtRecipe - Find
resources.getColor(...)(one-arg) callsorg.openrewrite.kotlin.android.FindResourcesGetColor$KtRecipe - Find
Handler()constructor calls without an explicitLooperorg.openrewrite.kotlin.android.FindBareHandlerConstructor$KtRecipe - Find
kotlinx.android.synthetic.*importsorg.openrewrite.kotlin.android.FindKotlinAndroidSyntheticImports$KtRecipe - Find
kotlinx.android.parcelimportsorg.openrewrite.kotlin.android.FindDeprecatedParcelizeImport$KtRecipe - Find
startActivityForResultcallsorg.openrewrite.kotlin.android.FindStartActivityForResult$KtRecipe - Find
onActivityResultoverridesorg.openrewrite.kotlin.android.FindOnActivityResultOverride$KtRecipe - Find direct
requestPermissions(...)callsorg.openrewrite.kotlin.android.FindRequestPermissions$KtRecipe - Find
onRequestPermissionsResultoverridesorg.openrewrite.kotlin.android.FindOnRequestPermissionsResultOverride$KtRecipe - Find
LocalBroadcastManager.getInstance(...)usageorg.openrewrite.kotlin.android.FindLocalBroadcastManager$KtRecipe - Find
Fragment.setRetainInstance(true)callsorg.openrewrite.kotlin.android.FindFragmentSetRetainInstance$KtRecipe - Find
FragmentManager.executePendingTransactions()callsorg.openrewrite.kotlin.android.FindFragmentManagerExecutePendingTransactions$KtRecipe - Find
Fragment.onAttach(Activity)overridesorg.openrewrite.kotlin.android.FindFragmentOnAttachActivity$KtRecipe - Find
Fragment.onActivityCreatedoverridesorg.openrewrite.kotlin.android.FindFragmentOnActivityCreated$KtRecipe - Find
AlertDialog.Builder(this)constructionsorg.openrewrite.kotlin.android.FindAlertDialogBuilderConstructor$KtRecipe - Find
startService(...)callsorg.openrewrite.kotlin.android.FindStartService$KtRecipe - Find
PreferenceManager.getDefaultSharedPreferences(...)callsorg.openrewrite.kotlin.android.FindPreferenceManagerGetDefaultSharedPreferences$KtRecipe - Find
android.preference.PreferenceManagerimportsorg.openrewrite.kotlin.android.FindPreferenceManagerImport$KtRecipe - Find
Vibrator.vibrate(long)(one-arg) callsorg.openrewrite.kotlin.android.FindVibratorVibrateLong$KtRecipe - Find
Context.registerReceiver(...)callsorg.openrewrite.kotlin.android.FindContextRegisterReceiver$KtRecipe - Find
MutableLiveDataallocationsorg.openrewrite.kotlin.android.FindMutableLiveDataAllocation$KtRecipe
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats