[Android Q&A, Help & Troubleshooting] elproduc3r:
Can someone help me, I've tried everything I can think of. I'm trying to build an xposed mod to replace the battery charging icons on my s4 (custom stock rooted touchwiz rom).

So far I was able to get [MENTION=4419114]rovo89[/MENTION] Red Clock tutorial to work, and i've even decompiled a few xposed battery tweak mods but i can't seem to replace the charging icons on my s4.

Here is my latest attempt

package com.elproduc3r.android.xposed.mods.redclock;

import com.elproduc3r.android.xposed.modules.redclock.R;

import android.content.res.XModuleResources;
import android.content.res.XResources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.widget.TextView;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;

public class redclock implements IXposedHookZygoteInit, IXposedHookInitPackageResources, IXposedHookLoadPackage {
private static String MODULE_PATH = null;

@Override
public void initZygote(StartupParam startupParam) throws Throwable {
// TODO Auto-generated method stub
MODULE_PATH = startupParam.modulePath;

//	XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, null);
//	XResources.setSystemWideReplacement("android", "drawable","stat_sys_battery_charge", modRes.fwd(R.drawable.stat_sys_battery_charge));
}

@Override
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui"))
return;

XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
resparam.res.setReplacement("com.android.systemui", "drawable", "stat_sys_battery_charge", modRes.fwd(R.drawable.stat_sys_battery_charge));
}

//change clock text color
public void handleLoadPackage(final LoadPackageParam lpparam)throws Throwable {

if (!lpparam.packageName.equals("com.android.systemui")){
return;
}

findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader, "updateClock", new XC_MethodHook() {

@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
TextView tv = (TextView) param.thisObject;
tv.setTextColor(Color.parseColor("#33B5E5"));
}
});
}
}

Here is my stat_sys_battery_charge.xml in drawable folder

<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="15">
<animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim15" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim29" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim43" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim57" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim71" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim85" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim100" />
</animation-list>
</item>
<item android:maxLevel="29">
<animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim29" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim43" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim57" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim71" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim85" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim100" />
</animation-list>
</item>
<item android:maxLevel="43">
<animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim43" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim57" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim71" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim85" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim100" />
</animation-list>
</item>
<item android:maxLevel="57">
<animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim57" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim71" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim85" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim100" />
</animation-list>
</item>
<item android:maxLevel="71">
<animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim71" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim85" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim100" />
</animation-list>
</item>
<item android:maxLevel="85">
<animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim85" />
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim100" />
</animation-list>
</item>
<item android:maxLevel="100">
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="2000" android:drawable="@drawable/stat_sys_battery_charge_anim100" />
</animation-list>
</item>
<item android:drawable="@drawable/stat_sys_battery_charge_anim100" android:maxLevel="101" />
</level-list>

All of my anim.png files are present, but seems like the xml file is not found since this is the error in xposed.log

Loading Xposed v42 (for Zygote)...
Loading modules from /data/app/com.elproduc3r.android.xposed.modules.redclock-1.apk
Loading class com.elproduc3r.android.xposed.mods.redclock.redclock
android.content.res.Resources$NotFoundException: com.android.systemui:drawable/stat_sys_battery_charge
at android.content.res.XResources.setReplacement(XResources.java:261)
at com.elproduc3r.android.xposed.mods.redclock.redclock.handleInitPackageResources(redclock.java:40)
at de.robv.android.xposed.IXposedHookInitPackageResources$Wrapper.handleInitPackageResources(IXposedHookInitPackageResources.java:20)
at de.robv.android.xposed.callbacks.XC_InitPackageResources.call(XC_InitPackageResources.java:28)
at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:70)
at de.robv.android.xposed.XposedBridge$1.afterHookedMethod(XposedBridge.java:668)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:561)
at android.app.ActivityThread.getTopLevelResources(Native Method)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1846)
at android.app.LoadedApk.getResources(LoadedApk.java:481)
at android.app.ContextImpl.init(ContextImpl.java:2343)
at android.app.ContextImpl.init(ContextImpl.java:2336)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4506)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:547)
at android.app.ActivityThread.handleBindApplication(Native Method)
at android.app.ActivityThread.access$1400(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126)
at dalvik.system.NativeStart.main(Native Method)

Can someone please show me what i'm doing wrong?