i have tried and searched for days and was unable to come up with any solution for my problem:
I am trying to install a .kl file in /system/usr/keylayout to remap some keyboard keys for my app. I have the proper .kl file in the right format: Vender_XXXX_Product_XXXX.kl and it works if i copy it by using root explorer.
But I want it to be install (without root) by installing my app. Which means it has to be include in the .apk file and copied during installation!?
My approach so far was either with using a receiver and the QUERY_KEYBOARD_LAYOUTS intent.
For that a .kcm file is needed. That did not work with my phone (Galaxy S3). I do not know why but it does not show the PHYSICAL_KEYBOARD settings item in settings :(
Anyways i think/hope the better way is by NDK:
I tried using the ndk and was able to integrate some native c into my application but no "source" files like my .kl file.
I was hoping that a device.mk file would somehow be able to copy my .kl file to /system like so:
device.mk
PRODUCT_COPY_FILES +=
$(LOCAL_PATH)/Vendor_XXXX_Product_XXXX.kl:system/usr/keylayout/Vendor_XXXX_Product_XXXX.kl
Is that at all possible? To use the NDK to "install" a file to /system automatically while installing the actual apk?
And if so how do you do that? I am confused about the whole makefile thing and NDK. Never use that before and I am quite bad with c.
If any of you guys know how to do what I am asking ... please let me know. It would be greatly appreciated!
It's not impossible to install a .kcm file with an apk package. In fact that is just how layout apps do it. You are on the right track with the QUERY_KEYBOARD_LAYOUT.
I wanted to install a .kl file, just like you, but I couldn't find any good info on it. So instead I just used the map keyword in my .kcm file, it has the exact same effect.
Check out my source here, where I allow the user to add the se_sv_dvorak layout kcm without rooting the phone: https://github.com/innsmouthrain/se_sv_dvorak
But I want it to be install (without root) by installing my app.
That is not possible. Apps do not have write access to /system/usr/, unless they are running as root.
To use the NDK to "install" a file to /system automatically while installing the actual apk?
It is doubly impossible:
Your app does not get control when installing
Code written using the NDK does not gain any additional OS rights, and so such code cannot write to /system/usr/, except when running as root
Related
I have installed Laravel on my Android mobile phone using Termux. The problem is that I do not know where it is installed and therefore I can't put the project files into a text editor on the mobile phone. Also, I can't find the project folder when I connect the mobile to my laptop and use search(through hidden files as well). I have tried to go up in folder structure using $cd .. in terminux, up to a point where the permission was restricted, so I didn't figured out where those folders would possibly be. Any suggestion would be appreciated :).
OK, so I found the answer. You need to change the current folder in which Termux is installed(data/data/com.termux/files/) to a folder where you can access your files with a file explorer(in my case I used sdcard) like so:
$cd /sdcard
Then, if u run Android 6 or higher, you need to allow termux to create new directories using the command:
$termux-setup-storage
After that you are able to create a new directory in sdcard with
$mkdir YourDirectory
and you are able to access it. Good luck!
My laptop crashed and i lost my android project ive been working on for the past 6 month. I still have the debug version on my phone. Is there a way i can get the code from that?
Your best bet would be to download the APK from the device using "adb shell pm path [package-name]" to see where the APK is installed, then "adb pull [path]" to download the file on your disk.
Then use a program such as dex2jar to get the class files, and another Java decompiler to get something as close to the source code.
Getting back the XML resources is a bit more tricky. All I can think of is running "aapt dump xmltree [your-app.apk] [path-of-xml]" to get a dump of what your XML resource looks like, but you'd still have to build XML from that manually.
Hopefully you didn't have native code (.so files), otherwise you're probably screwed.
Oh ok - sorry i misunderstood the question in the first place. For the installed apk there could be a solution in this question: Does Android keep the .apk files? if so where?
I have downloaded and successfully build the AOSP for marshmallow (android-6.0.1_r79). Than I made some changes to the stockkeyboard (regarding to my other topic, but not relevant here). The file which I modified was this here:
packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java
I compiled the code and it was successful too. But than I realize I face some problems.
I mounted the system.img and get into the path: /system/app/LatinIME/
I decompiled the app to check if the modification there is available and here is the problem.
This APK does not contain any Java Sources?! Its just XML regarding to the layout. When I replace my old Stockkeyboard with this one, it is still perfectly working? So I got not clue what's going on.
Question regarding to this topic are:
How can I make a modification to the stock keyboard LatinIME
Building this new AOSP image with the new keyboard
And extracting the new keyboardj (APK) out of this image to install it on my device (Root permissions are of course available)
What I have tried:
Modyfing the following Java file: packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java
Compiling the complete project (make -j4 and just the keyboard: make -j LatinIME)
Extracting the system.img -> mounting it -> pulling /system/app/LatinIME/LatinIME.apk out of this
Replacing my own keyboard with the modified stock keyboard
My steps are as described not working. The keyboard appears and its working but the modification seems to be missing. Also by decompiling it, there are no Java sources within it.
you do:
cd packages/inputmethods/LatinIME
do your code changes
$mm -B
croot
adb root
adb remount
adb push out/target/product/your_product_name/system/app/LatinIME/LatinIME.apk
/system/app/LatinIME/
adb reboot
LatingIME.apk is about 18MB
You will find intermediate files ( the ones taken into compilation ) here :
out/target/common/obj/APPS/LatinIME_intermediates/
Here is the fresh and fully functional AOSP keyboard with glide typeing enabled
I'm trying to release an android app with system privileges using the following link:
http://paulononaka.wordpress.com/2011/10/19/apk-with-system-privileges/
my OS knowlage is somewhat poor and i cant get my system to recognize "keytool-importkeypair" as a command.
I'm using Win ex.
added the folder to the system PATH.
started cmd as Admin.
changed the keytool-importkeypair file to: exe,com and bat files, the system could recognize the file then, but still didnt do the right oporation.
May it be a file for linux only? i really don't know much about system command files, so any help would be great.
Thanks.
keytool-importkeypair is a Linux file. It will not work on Windows. To use this as a command on Linux:
1) Download the keytool-importkeypair from following location and save it to the same folder where platform certs are present
https://github.com/getfatday/keytool-importkeypair
2) Once the file is there, you can simply use it by typing
$./keytool-importkeypair "rest of the command"
Well, it seems to be a linux file.. just need to know how to add it to the linux path now.
am almost done with my project in android, now I want to make the executable version of the application.
I need to demonstrate it in .exe form as soft app as on emulator, not by built and debug process from eclipse.
what the op is asking for is simple - he wants to create a MS Windows program file that runs just like the APK he's made.
Unfortunately this cannot be done. The only way to 'show off' your program is as people have stated:
Through the emulator on Windows
On an acual device (Once installed, you can disconnect the device from the computer and use it like a normal app)
You can't convert an APK file into a .exe file. APK files hold Android apps as self-installable files already - opening an APK file on a phone or the emulator will start the installation process. It sounds like you just want to sign the app with a 'proper' key rather than using a debug key. To do that, read the official page on signing apps.
You don't need to create a .EXE file for doing what you want. You can just create a bat file that executes adb commands that will: install and start your application in the emulator. I guess, the problem here is that you don't understand how the APK files work... I'm just saying.
OK... in order to install an Android application using adb (which is basically what Eclipse does in the background) you need to do this:
adb install path/name_app.apk
Then, you can start the application by using adb shell am command. You can find info here: http://pdk.android.com/online-pdk/guide/instrumentation_testing.html
Another thing you have to take in account is that you will have to run the AVD before installing and executing your application: http://developer.android.com/guide/developing/tools/avd.html
All those commands you have to execute (may be using a .bat file as I mentioned before) are executables that you can find in the android-sdk\tools directory.
When I have a client that want's to show an app, at conference for example, I always use Bluestacks it's not perfect but it allows you to run android apps on your computer without doing all the technical stuff (like installing an emulator etc).
To install an app on your you computer using the Bluestacks device/emulator you simply click on the apk.
http://bluestacks.com/
Once you create a project/application in Eclipse then along with this you also have created the .apk file. Android can run .apk files, so go to the place where your project have been saved and open it, like this Open Project -->bin-->.apk.
Now send the .apk file to your android phone through Bluetooth or copy it.