[Frameworks] t2107:
All credit goes to Rovo89 and the original tutorial here at: https://github.com/rovo89/XposedBridge/wiki/Development-tutorial

I would suggest reading that page first because it explains a lot of the background theory of how Xposed operates.

A brief overview of what has changed from Rovo89's original tutorial and the one presented in this thread:

Source code changed: none (pure copy and paste)

Files modified: XposedBridgeApi.jar - all the *.class files were deleted from this archive because Aide offers no elegant way to link the file into a project without including it in the final build. The problem that occurs if the .class files are not deleted is that all the classes are included in the final build of the module, and it causes fatal errors which prevented the module from executing.

Device settings modified: The heapsize on my Galaxy Note had to be increased from 256mb to 512mb because Aide was throwing "out of memory" errors and would freeze during compilation of the code.

If you can adapt those changes yourself, then you can follow Rovo89's original tutorial on your own. For everyone else, you can follow mine step by step until you understand it all. Permission for Rovo89 is granted to copy/paste any of my changes into his original tutorial if it would help to be all unified.

Here is how to adapt that tutorial so you can develop Xposed modules on your Android device, i.e, develop without using a PC.

Step 1 - Download the required apps onto your device from the Play Store:

Aide is the IDE and Java compiler

Build Prop Editor is for increasing your devices stack size

Arc File Manager is for deleting some contents from a jar file

Step 2 - Creating a new project

Open Aide

Create new project -> Android App -> Hello World

Name: MyApp

Package Name: com.mycompany.myapp

Step 3 - Adding the XposedBridge library

Download the XposedBridgeApi.jar file from here - as per usual, full credit goes to Rovo89

Using Arc File manager copy XposedBridgeApi.jar to the 'libs' folder in your MyApp project folder.

Open XposedBridgeApi.jar in Arc File Manager and delete every *.class file inside. Don't delete the *.java files

Exit Arc File Manager and uninstall it if you don't need it for anything else.

Step 4 - Make your project recognized by Xposed

Back in Aide again, open AndroidManifest.xml in your project's root folder.

Paste the following lines into the <Application> section

<meta-data android:value="true" android:name="xposedmodule"/>
<meta-data android:value="2.4*" android:name="xposedminversion"/>
<meta-data android:value="Demonstration of the Xposed framework.\nMakes the status bar clock red." android:name="xposeddescription"/>

As you can see I am using Xposed 2.4.x - if your version is different, adjust the above lines accordingly.

See Rovo89's original tutorial if you need more context.

Step 5 - Add your source code

In your Aide project navigate to src/com/mycompany/myapp

Click - Add new Class here...

Name: xposedhook

Copy and paste the following code into xposedhook.java (also note, this is verbatim from Rovo89's tutorial)

package com.mycompany.myapp;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import android.graphics.Color;
import android.widget.TextView;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class Tutorial implements IXposedHookLoadPackage {
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;
String text = tv.getText().toString();
tv.setText(text + " :)");
tv.setTextColor(Color.RED);
}
});
}
}

Step 6 - Adding the class entry point

In Aide navigate to the 'assets' folder and create a new file named 'xposed_init'

Paste into the xposed_init file the following line:

com.mycompany.myapp.xposedhook

Step 7 (OPTIONAL) - increase the heap size of your device

I was getting "out of memory" errors when I tried to compile/run my app. So the solution was to increase the heap size using Build Prop Editor which you already installed from the play store.

Open Build Prop Editor and change 'dalvik.vm.heapsize' to at least 512m. Mine was 256 by default. If your's is already 512m or higher then you can skip this step.

Restart your device after this step, but save your progress in Aide first.

Step 8 - Congratulations, you made it! now its time to open your project in Aide again (if you restarted your device in the previous step) and hit "Run" from the menu. Aide will give you a Cancel/Install choice to which you will select Install. Your Module will now be in the Xposed modules list, but it will be unselected. Enable your module by opening Xposed installer and ticking the box next to your module.

Restart your device. If the clock is red, then you should be very happy; you just created your first Xposed module. Now you can have fun with building modules with Aide and Xposed :good: