Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,740,872 Members 52,859 Now Online
XDA Developers Android and Mobile Development Forum

[Tutorial] Xposed - Develop modules on your Android phone or tablet using Aide

Tip us?
 
t2107
Old
(Last edited by t2107; 5th February 2014 at 07:19 AM.)
#1  
Junior Member - OP
Thanks Meter 5
Posts: 24
Join Date: Nov 2013
Cool [Tutorial] Xposed - Develop modules on your Android phone or tablet using Aide

All credit goes to Rovo89 and the original tutorial here at: https://github.com/rovo89/XposedBrid...pment-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:

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
Code:
Select Code
<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)
Code:
Select Code
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:
Code:
Select Code
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
The Following 5 Users Say Thank You to t2107 For This Useful Post: [ Click to Expand ]
 
neXus PRIME
Old
#2  
neXus PRIME's Avatar
Recognized Contributor
Thanks Meter 3007
Posts: 2,965
Join Date: Nov 2011
Location: Lahore, Pakistan
Great tutorial man.

I created some modules on my pc using a tutorial and those worked fine. Then after my phone had a firmware update, i tried them again but they didnt work.
I tried building again n again n again.... every other module by other ppl were working but the one i compiled didnt work.

Then i saw ur guide and made the test module on phone and it WORKED! !

Now i guess the problem on pc was that the IDEs were adding unnecessary files... or maybe the trick of deleting the class files inside the API jar was the one which worked.

Anyways, great help, now i can continue with my project.
The Following User Says Thank You to neXus PRIME For This Useful Post: [ Click to Expand ]
Tags
aide, create, module, modules, xposed
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes