ximsfei / Android-skin-support

Android-skin-support is an easy dynamic skin framework to use for Android, Only one line of code to integrate it. Android 换肤框架, 极低的学习成本, 极好的用户体验. "一行"代码就可以实现换肤, 你值得拥有!!!
MIT License
6.42k stars 1.08k forks source link

Android10 以上 target 使用hide 反射回崩溃 #419

Open snailGoing opened 4 years ago

snailGoing commented 4 years ago
private void installLayoutFactory(Context context) {
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    try {
        Field field = LayoutInflater.class.getDeclaredField("mFactorySet");
        field.setAccessible(true);
        field.setBoolean(layoutInflater, false);
        LayoutInflaterCompat.setFactory(layoutInflater, getSkinDelegate(context));
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
ximsfei commented 4 years ago

最新的代码已经去掉了这个反射

xiaoxing1992 commented 3 years ago

最新的代码已经去掉了这个反射

你好 安卓11切换皮肤失败 不知怎么解决 求大神帮忙看看

jhwsx commented 3 years ago

你好 安卓11切换皮肤失败 不知怎么解决 求大神帮忙看看

你是什么报错也没有说明一下?

xiaoxing1992 commented 3 years ago

你好 安卓11切换皮肤失败 不知怎么解决 求大神帮忙看看

你是什么报错也没有说明一下?

您好 现在是报了新的问题: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:399) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) Caused by: java.lang.NoSuchFieldError: No static field abc_text_select_handle_left_mtrl_dark of type I in class Landroidx/appcompat/R$drawable; or its superclasses (declaration of 'androidx.appcompat.R$drawable' appears in /data/app/com.motoband-jlhOcZphgUP4kietcmq21A==/base.apk!classes2.dex) at skin.support.content.res.SkinCompatDrawableManager.(SkinCompatDrawableManager.java:108) at skin.support.content.res.SkinCompatDrawableManager.get(SkinCompatDrawableManager.java:60) at skin.support.content.res.SkinCompatVectorResources.clear(SkinCompatVectorResources.java:30) at skin.support.content.res.SkinCompatResources.setupSkin(SkinCompatResources.java:76) at com.motoband.ui.view.skin.MBSkinSDCardLoader.loadSkinInBackground(MBSkinSDCardLoader.java:39) at skin.support.SkinCompatManager$SkinLoadTask.doInBackground(SkinCompatManager.java:394) at skin.support.SkinCompatManager$SkinLoadTask.doInBackground(SkinCompatManager.java:364) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:919) 

我把appcompat降级到1.2.0还是会出现这个问题 求解决办法 感谢您回复我

hardyio commented 2 years ago

你好 安卓11切换皮肤失败 不知怎么解决 求大神帮忙看看

你是什么报错也没有说明一下?

您好 现在是报了新的问题: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:399) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) Caused by: java.lang.NoSuchFieldError: No static field abc_text_select_handle_left_mtrl_dark of type I in class Landroidx/appcompat/R$drawable; or its superclasses (declaration of 'androidx.appcompat.R$drawable' appears in /data/app/com.motoband-jlhOcZphgUP4kietcmq21A==/base.apk!classes2.dex) at skin.support.content.res.SkinCompatDrawableManager.(SkinCompatDrawableManager.java:108) at skin.support.content.res.SkinCompatDrawableManager.get(SkinCompatDrawableManager.java:60) at skin.support.content.res.SkinCompatVectorResources.clear(SkinCompatVectorResources.java:30) at skin.support.content.res.SkinCompatResources.setupSkin(SkinCompatResources.java:76) at com.motoband.ui.view.skin.MBSkinSDCardLoader.loadSkinInBackground(MBSkinSDCardLoader.java:39) at skin.support.SkinCompatManager$SkinLoadTask.doInBackground(SkinCompatManager.java:394) at skin.support.SkinCompatManager$SkinLoadTask.doInBackground(SkinCompatManager.java:364) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:919) 

我把appcompat降级到1.2.0还是会出现这个问题 求解决办法 感谢您回复我

terminal 执行gradlew :app:dependencies 查看实际引用的appcompat版本 可以用下面代码强制设置成具体版本 configurations.all { resolutionStrategy { force 'androidx.appcompat:appcompat:1.2.0' } }