Skip to content Skip to sidebar Skip to footer

Classnotfoundexception: Config_inputeventcompatprocessoroverrideclassname Androidx, Running On Andoridx Crashes

After Migrating to AndroidX(29) running on the AndroidX device Crashes showing ClassNotFoundException: config_inputEventCompatProcessorOverrideClassName the project compiles and

Solution 1:

I have faced with the same issue on Android 10. I used the Restring library which injects a custom Resource implementation through attachBaseContext(newBase: Context). Everyone here mentioned that constructor of Resource marked as deprecated, but it doesn't really cause a problem.

I was digging into the Android source code and I found the real reason that can throw NPE.

Affected lines from ViewRootImpl.java:

StringprocessorOverrideName= context.getResources().getString(
                                    R.string.config_inputEventCompatProcessorOverrideClassName);
        if (processorOverrideName.isEmpty()) {
            // No compatibility processor override, using default.
            mInputCompatProcessor = newInputEventCompatProcessor(context);
        } else {
            InputEventCompatProcessorcompatProcessor=null;
            try {
                final Class<? extendsInputEventCompatProcessor> klass =
                        (Class<? extendsInputEventCompatProcessor>) Class.forName(
                                processorOverrideName);
                compatProcessor = klass.getConstructor(Context.class).newInstance(context);
            } catch (Exception e) {
                Log.e(TAG, "Unable to create the InputEventCompatProcessor. ", e);
            } finally {
                mInputCompatProcessor = compatProcessor;
            }
        }

In my case, using Restring library, I defined a new way to resolve a string key and return text. If the key isn't available in my string repository (simple HashMap) or as a string resource, it returns with the key itself. So never will be empty, but according to the code it will try to load as custom InputEventCompatProcessor that will fail and mInputCompatProcessor will be null.

Make sure all verions of getText() in your custom Resource respect the original behavior and it won't cause NPE crash. For example make sure R.string.config_inputEventCompatProcessorOverrideClassName resource will be resolved as empty string when it's not available.

This will solve the real issue and you can still use the deprecated Resource constructor.

Solution 2:

There are a couple of clarifications needed to answer your question

  1. Was the app working fine before you migrated to androidx?

  2. Does the app work without crashing on other devices but crashes on just android 10.0?

  3. did you refactor your package names correctly? If your file names in the manifest or generated code have a package name starting with capital letters, 'class not found exception' could result

You can try pasting (if possible) the Github link to the whole project for proper debugging.

However, from the code you pasted, your minsdkversion= 16 in your project build.gradle ext block differs from the minsdkversion= 15 in your app build.gradle file. The targetsdkversion also differs in the two files

Solution 3:

thanks for all the support i solved the issues, this was due to the usage of deprecated method, this was not related to migration

@Override
public Resources getResources() {
    return new CustomResources(sharedPrefence, getAssets(), super.getResources().getDisplayMetrics(), super.getResources().getConfiguration());
}

custom Resources class cannot be used in this way in androidX, by removing this method from Baseactivity.java solved the problem, thanks for all your suppor

Post a Comment for "Classnotfoundexception: Config_inputeventcompatprocessoroverrideclassname Androidx, Running On Andoridx Crashes"