XposedBridge
XposedBridge copied to clipboard
Development tutorial updates
Hi,
I have two suggestions for updates to the development tutorial wiki, specifically for Android Studio.
- With the jar file: Don't put in libs/ dir, put in root dir of the Android project. Right click -> add as library, then, build -> edit libraries and dependencies -> app -> dependencies (top bar) -> jar -> scope -> change to provided
- With the assets folder: Gradle expects it to be in app/src/main/assets
Thanks, David
I'd like to add another suggestion:
Below
XposedBridgeApi.jar
Next, make the XposedBridge API known to the project. You can download XposedBridgeApi-
.jar from the first post of this XDA thread. Copy it into a subfolder called lib. Then right-click on it and select Build Path => Add to Build Path. The from the file name is the one you insert as xposedminversion in the manifest. Make sure that the API classes are not included (but only referenced) in your compiled APK, otherwise you will get an IllegalAccessError. Files in the libs (with "s") folder are automatically included by Eclipse, so don't put the API file there.
It should say:
Alternative for gradle users: Add this to your build.gradle
dependencies { provided 'de.robv.android.xposed:api:65' //other dependencies... }
As this is way easier to use and manage.
Add this to your build.gradle
Guess why this isn't mentioned there? Because I'm still working on the API via Gradle. Please leave the announcement up to me.
Then you might be happy to hear that using the API via gradle works without issues for me. (I had just discovered the upload at bintray and as it was working without problem, so I didn't think it would be that new)
for me, i just using ant
way, and a modified gradle.
android {
// ....
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
androidTest.setRoot('tests')
}
// ....
}
dependencies {
// I put the compile dependencies in lib directory, for example, hidden api, xposed bridge library
provided fileTree(dir: 'lib', include: ['*.jar'])
// And, for libs, real dependencies, the same directory in ant way
compile fileTree(dir: 'libs', include: ['*.jar'])
}
tasks.withType(JavaCompile) {
// for hidden api, should override android.jar
options.compilerArgs << '-Xbootclasspath/p:' + fileTree(dir: 'lib', include: ['*.jar']).asPath
}
And, for ant's custom_rules.xml
<target name="-pre-compile">
<!-- add *.jar to compilier library -->
<pathconvert property="bootstrap.class.path">
<fileset dir="lib" includes="*.jar" />
<path refid="project.target.class.path" />
</pathconvert>
<path id="project.target.class.path">
<pathelement path="${bootstrap.class.path}" />
</path>
<!-- ... -->
</target>
And, this is the project: https://github.com/liudongmiao/ForceStopGB/
Both ant debug
(should run android update project -p . -t "android-23"
to generate build.xml) or gradle aDebug
work. It works with ant.properties
(for keys) too.
Then you might be happy to hear that using the API via gradle works without issues for me.
That's great! I'm sure it will make the setup for a new module project much easier in the future.
The new way to reference the Xposed APIs is published now: https://github.com/rovo89/XposedBridge/wiki/Using-the-Xposed-Framework-API
The tutorial still needs updates in several places though to match the Android Studio way... and I guess I need to find a way to create a new project without all the default stuff like support library, unit tests etc.
@rovo89
There is also documentation available for the API (see below). Unfortunately, I didn't find any good way to enable automatic download of the API sources, except using both of these lines:
provided 'de.robv.android.xposed:api:81' provided 'de.robv.android.xposed:api:81:sources'
The way Gradle caches the files, Android Studio will set up the second jar as source for the first one automatically. Better recommendations are welcome!
The sources are automatically downloaded and attached, if the library is used with compile
. Afterwards it also works in provided
mode. I think the only thing going wrong is that gradle doesn't load the sources into the cache if in provided
mode. You might want to file a bug report for this, I'm sure this is not intended.
To get the example compiling with the tools 'android' and 'ant', you need to create a file 'custom_rules.xml' in the root directory of the example. (put it to 'XposedExamples-master/RedClock/custom_rules.xml') Content of that file is the following code section:
<project name="RedClock" default="help">
<!--
put this file into project root to use it with following 2 shell commands:
#> android update project -p . - -name RedClock - -target 3
#> ant -f build.xml debug
you might need to adapt target number to reflect to Android SDK 4.0.x
to get the correct number for your development setup, use shell command:
#> android list targets
-->
<target name="-pre-compile">
<!-- add *.jar to compilier library -->
<pathconvert property="bootstrap.class.path">
<fileset dir="lib" includes="*.jar" />
<path refid="project.target.class.path" />
</pathconvert>
<path id="project.target.class.path">
<pathelement path="${bootstrap.class.path}" />
</path>
<!-- ... -->
</target>
</project>
Thanks to liudongmiao post I could figure out, how to get it working.
Uploading custom_rules.xml.zip…