Qpython Bluetooth admin permission patch

Qpython for android is very handy for getting an idea up and running quickly. There is a problem with its bluetooth permissions though which means that whenever any Bluetooth related function is run, a permissions error occurs. Sometimes the error message says something about Bluetooth requiring administrator permission to be used but in this case I received a connection refused message:
SC20140330-181316

After searching online, there was only one post related to this on a forum. Luckily a user suggested that decompiling the .apk file, editing the AndroidManifest.xml file to give the Qpython app the correct permissions and then rebuilding the .apk file should fix the issue. To work with the .apk file I used apktool for decompiling and rebuilding. Here are the commands used:

Place the .apk file (in this case I renamed mine to test.apk) in the same directory as the apktool.jar file and run the following command to decompile the .apk file:

java -jar d test.apk

After the file is decompiled, open up the AndroidManifest.xml and add in the following line:

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" ⁄ >

So now we want to rebuild the .apk file. This is done with the following command: (Just make sure the dirctory given points to the folder containing the decompiled .apk file)

java -jar apktool.jar b /usr/local/bin/test

So now the .apk file has been rebuilt. Now it need to be signed before it can be installed on an android phone. SignAPK was used for this. This is the command used:

java -jar signapk.jar certificate.pem key.pk8 test.apk test_signed.apk

This will take test.apk, sign it and output test_signed.apk. Now the app can be transferred to a smartphone and installed. After the modified app was installed I managed to find and connect to my computer with no errors. Here is what it looked like in the terminal:
Selection_067

Here is the Qpython script used:

Download link to updated Qpython apk file.

This entry was posted in Qpython and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply