Driver's education quiz in Italian language [quiz per la patente in italiano] for Android platform.
This is a mini guide how to modify an application for android created online using AppsGeyser.
I have used a mac but there are no big changes if you are using another OS, Phonegap could be used as well.
I wanted to create an html-quiz to be used on an android tablet, and I found that AppsGeyser suits for that job , so I have created one with it.
After the quiz was created online, downloaded offline and installed on the tablet (Quiz.apk), I have found I could not play with it like was meant to.
I have discovered that my problem was I could not use an internet connection on the tablet that I borrowed, and the quiz created used external links to work.
The quiz did not start at all.
I have asked to people at AppsGeyser but I did not receive any answers, so I have decided to execute the app locally, simply changing some links and files internally, it's a matter of copying a library locally.
I am trying to explain here, the steps I followed.
Once I have downloaded ADT plugin for Eclipse (Android Development Tools), I was ready to start.
I renamed the .apk file to .zip , and unzipped , revealing the files. After having done such, I could see the tree structure contained:
After a quick research, I have found that I needed to change the link of the file contained in assets folder
assets/content_0.html from <script src="ajax.googleapis.com/ajax/libs/…"></script>
to <script src="jquery.min.js"></script>
To get things working, I downloaded and copied the script jquery.min.js
locally and added it to assets folder, like required. imho after that the quiz is finished for the first time, you should be able to start it again, like it should be; thus it should show 'Next question' message instead of 'Finish Quiz', once the test is over and you started the test a second time, you have answered the first question and you want to continue the test.
I need to be able to start the quiz again when the quiz is over.
so I added $('.next-question').val('next-question')
to the function try-again
question = 0;
score = 0;
answered = false;
At this point , I had to repack my tree-folder previously modified , first as a single .zip file and then renaming it as .apk file. Eventually I made it executable:
chmod +x Quiz.apk
Because OSX automatically creates always some hidden files, I removed them by doing:
zip -d Quiz.apk "META-INF*"
At this point I had to sign the application (otherwise one cannot install the app on the device) using an utility called keytool. To sign the app one needs a signature file. Usually is done without no particular parameters, using the command keytool -genkey -v -keystore android-test.keystore
. A file needed for the signature, a key - android-test.keystore, is created alongside the new. apk previously created. The .apk file is then optimized by another utility, zipalign.
Actually the precise command given was:
keytool -genkey -v -keystore debug.keystore -alias mykey -keyalg RSA -keysize 2048 -validity 20000Android keystore RSA key has generally validity for only 6 months by default, if I am not mistaken. I choose
20000 days for validity, meaning that after the app is signed, the signer certificate will expire roughly within 657 months.
Then, as I stated, I have used again the command line.
/Applications/adt-bundle-mac-x86_64-20130729/sdk/tools/zipalign -f -v 4 /Users/me/Documents/Quiz.apk /Users/me/Documents/Quiz_new.apk
Jarsigner and some of these other utilities used here, like zipalign, are found inside ADT - Android Developer Tools IDE.Quiz_new.apk
is the name for the newly archive created with zipalign, an alignment tool used to optimize Android files (.apk).
Was time to sign, first deleting the old .apk and renaming the new one (EGAF+Quiz.apk).
jarsigner -verbose -keystore debug.keystore EGAF+Quiz.apk
When everything is
done, the .apk file needs to be installed on the tablet (a Mediacom model, available in Italy).
USB debugging was enabled on tablet, and an USB cable provided by Mediacom was used to connect the tablet to the laptop.
I had some problems but nothing really unpleasant. As many other people before me, I had to manually update ADB (Android Debug Bridge) to support the USB device, although did not work at first sight:
/Applications/adt-bundle-mac-x86_64-20130729/sdk/tools/android update adb
It did eventually work, adding manually its Vendor-id to /Users/me/.android/adb_usb.ini before restarting again ADB server. This task is done again using terminal, or just using a text editor.
echo 0x2207 >> ~/.android/adb_usb.ini
/Applications/adt-bundle-mac-x86_64-20130729/sdk/platform-tools/adb install /Users/me/Documents/Quiz_new.apk
Please Tell me if you find errors, English is not my mother language.