[Q] How to use SU permissions in an app? - Android Q&A, Help & Troubleshooting

Hey everyone.
I'm developing an android application in java, and I'm pretty familiar with all that stuff, but now it's the first time when I need to use SU permissions.
The goal is to move some file from /system/ directory to SD, I tried to use renameTo method from File class, but it returns 0 (FALSE), which means that some error occured.
I also noticed that there was no Superuser app prompt, asking to confirm granting superuser permissions.
So, how do I replace files from /system/? Shall I use the same method but with some additions in manifest? Or is there any other way?
I already searched xda, googled for it, but I can't find any useful information. I also checked Android Superuser website and I didn't find any documentation or something like this.
Thanks in advance!
UPD: Found a solution http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/
thanks to stackoverflow
Sorry for this thread

Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums
Moving to Q&A

Related

[Solved][Q] .apk file questions

Hi everyone! I'm still relatively new to all these customizations that can be made on these phones, and I am curious about all these .apk files I keep seeing around. Everyone time one is posted, it says to push it to your phone to replace whatever file is there... The thing is, every time I read about it I find a new way of doing it. Some say to use root explorer, some say SGS tools app, some say to use easy installer, and I think I've even read to use ADB? I just was wondering what's the best method? Easiest method? Can you screw your phone up by replacing these files? I keep reading things like if you want to switch a camera in your ROM to a different version, just install the .apk! Or, if you want to use live wallpapers in a ROM that doesn't come with it, here is the .apk for that!
Any help is much appreciated!
Thanks guys!
tarastaryo said:
Hi everyone! I'm still relatively new to all these customizations that can be made on these phones, and I am curious about all these .apk files I keep seeing around. Everyone time one is posted, it says to push it to your phone to replace whatever file is there... The thing is, every time I read about it I find a new way of doing it. Some say to use root explorer, some say SGS tools app, some say to use easy installer, and I think I've even read to use ADB? I just was wondering what's the best method? Easiest method? Can you screw your phone up by replacing these files? I keep reading things like if you want to switch a camera in your ROM to a different version, just install the .apk! Or, if you want to use live wallpapers in a ROM that doesn't come with it, here is the .apk for that!
Any help is much appreciated!
Thanks guys!
Click to expand...
Click to collapse
You CAN screw your phone up if you do it to the wrong APK (like /system/framework/framework-res.apk, if you install a bad one, your phone won't boot, but there is an easy fix, nandroid!).
Basically all the methods do the same thing. In Android "Installing" an app is as easy as moving it to the correct location. All of these methods do just that.
The easiest way IS to probably use Root Explorer because you can rename the old one just in case, and it will handle the system read/write mounting for you. Plus GUIs are always easier.
So here's how it works: user apps go in /data/app, and system apps go in/system/app. User apps can't really mess anything up, but be careful with System ones. Live wallpapers, things of that nature usually don't hurt. Camera is ok to mess around with, too.
Edit: my ramblings are probably confusing, don't hesitate to ask me to clear something up
usually most apk files can be installed easily by transferring the file to the root of your internal sd card then go to MY FILES locate the apk file and click on it and it will ask you to install. Thats it. You can also root explorer and just place it in the system/app folder then reboot. I install all of my apks through the first way I mentioned. On my wife's Mytouch4g there is no my files so use Astro file manager. Come to think of it any file manager from the market will do. Good luck...
tarastaryo said:
Hi everyone! I'm still relatively new to all these customizations that can be made on these phones, and I am curious about all these .apk files I keep seeing around. Everyone time one is posted, it says to push it to your phone to replace whatever file is there... The thing is, every time I read about it I find a new way of doing it. Some say to use root explorer, some say SGS tools app, some say to use easy installer, and I think I've even read to use ADB? I just was wondering what's the best method? Easiest method? Can you screw your phone up by replacing these files? I keep reading things like if you want to switch a camera in your ROM to a different version, just install the .apk! Or, if you want to use live wallpapers in a ROM that doesn't come with it, here is the .apk for that!
Any help is much appreciated!
Thanks guys!
Click to expand...
Click to collapse
An apk is a specialized application file used by android (uses the same file headers as .zip files).
You are correct that there are various methods to push or move apk's to appropriate directories with in the phone. now as to which is easier or best, all methods work about the same, though there are minute differences.
If you want to move apk's into a certain directory while using a phone i find it easiest to use a file manager like root explorer that has root permissions to move apks around. keep in mind that when moving system files most often you will have to reboot for the changes to take effect with out bugs.
If instead you want to use a computer personally i find ADB to be the easiest. After installing the android sdk you will have to navigate into the android sdk directory then to the platform-tools directory within the android sdk folder. then in command prompt type " adb push <directory of file on your computer> /<directory of where you want it on your phone> hit enter and all is gravy. keep in mind that pushing/moving files to your phone using adb works the best when in recovery mode.
as to which of these operations is the best is a personal decision personally i like to use adb to move around system files and root explorer for applications.
hope this helps
Thanks guys!! Ok, so just to be sure. I'm currently running the Malice rom, and somewhere in the threads is the LiveWallpaperPicker.apk
So all I have to do is download this, place it on the root of my internal SD card, go into file manager and find it, click on it, and it will ask me to install it? It's really that easy??
Or, should I download root explorer and copy and paste it to a specific place?
tarastaryo said:
Thanks guys!! Ok, so just to be sure. I'm currently running the Malice rom, and somewhere in the threads is the LiveWallpaperPicker.apk
So all I have to do is download this, place it on the root of my internal SD card, go into file manager and find it, click on it, and it will ask me to install it? It's really that easy??
Or, should I download root explorer and copy and paste it to a specific place?
Click to expand...
Click to collapse
For that file you will need to place it in /system/app (it can't be installed normally because it's a system app). So you need something like Root Explorer
I think EStrongs File explorer is a decent free alternative, but when I tried it a couple months ago I had no luck with it so I just bought Root Explorer (good investment)
The guide in my signature touches on this, but BT has you covered. I am also a huge advocate of Root Explorer.
Just take the .apk, move it to system/apps and I reboot, but it may not be necessary... no need to click on it and select install, as BT referenced.
Thanks so much everyone! Just purchased root explorer and will try this out.
IT WORKED IT WORKED IT WORKED!!!!!!!!!!!!!!!!!!!!
After I rebooted, none of my widgets could load, but I have live wallpapers again! I love learning new stuff! Thanks sooooooooooooooooo much! You guys are the BEST!!!
Odd about the widgets. Were you able to just remove them and re-add them back?
Yep, just deleted them off my home screen and added them back again. All of them had errors saying widget could not load

modifying 2nd.zip package in root sdcardv4

I unzipped the 2nd_Albert_APP_update.zip and found the structure
\system\app and list of *.apk files.
question 1:
can I remove an apk file from 2nd_Albert_APP_update.zip in \system\app like twitter.apk without breaking the install process?
question 2:
Can I just add my own demo.apk files by simply copying them and saving the same archive and location mentioned above?
rp201 said:
I unzipped the 2nd_Albert_APP_update.zip and found the structure
\system\app and list of *.apk files.
question 1:
can I remove an apk file from 2nd_Albert_APP_update.zip in \system\app like twitter.apk without breaking the install process?
question 2:
Can I just add my own demo.apk files by simply copying them and saving the same archive and location mentioned above?
Click to expand...
Click to collapse
First of all wrong section. Second off if verification signatures are off, then you might* be able to assuming he used the package command, you might be able too.
Loglud said:
First of all wrong section. Second off if verification signatures are off, then you might* be able to assuming he used the package command, you might be able too.
Click to expand...
Click to collapse
sorry for wrong section, I was stuck between sections where to post.
I figured a metafile edit or package signing tool might be needed I did not want a simple yes response. I guess I will hijack my own post and change it a more dev type question.
Any rough steps you can give me to do this myself that I can then do searches on?
figure I'll have to
download android sdk.
examine metafile xy.z
look for section [] and edit
place apks in structure
buildpacktool.exe to look for.
any help would be greatly appreciated
thanks
rp201 said:
sorry for wrong section, I was stuck between sections where to post.
I figured a metafile edit or package signing tool might be needed I did not want a simple yes response. I guess I will hijack my own post and change it a more dev type question.
Any rough steps you can give me to do this myself that I can then do searches on?
figure I'll have to
download android sdk.
examine metafile xy.z
look for section [] and edit
place apks in structure
buildpacktool.exe to look for.
any help would be greatly appreciated
thanks
Click to expand...
Click to collapse
um sure. So first of the great thing is you really shouldn't have to do much. The basic premiss of this is that it uses a update.zip to flash via CWM, which means you shouldnt have to sign the package. Basic premiss, is I would first try unziping deleting and putting packages into ./system/app/ rezipping and then trying to flash that. That should be good enough to make your own. Second off if you really want to, you can look at the meta-data/.../update-script. There are some good guides on how to script this file.
http://forum.xda-developers.com/showthread.php?t=994940

[Q] how do i?

Hi all. This is my first post and no doubt my question will probably already have been answered so here goes. my Samsung GT-19100 keeps telling me that there is insufficient memory when trying to download. I have plenty of memory spare on the phone 10 gb actually on sd card. I have looked up for answers and seem to have found it, unfortunately I don't know how to go about it. The information I found is saying I need to delete the .odex file in the app data just don't know where to find this file. Any help is very much appreciated. Thank You so much to everyone that has read this. Thanks. Paul.
keo2458 said:
Hi all. This is my first post and no doubt my question will probably already have been answered so here goes. my Samsung GT-19100 keeps telling me that there is insufficient memory when trying to download. I have plenty of memory spare on the phone 10 gb actually on sd card. I have looked up for answers and seem to have found it, unfortunately I don't know how to go about it. The information I found is saying I need to delete the .odex file in the app data just don't know where to find this file. Any help is very much appreciated. Thank You so much to everyone that has read this. Thanks. Paul.
Click to expand...
Click to collapse
Is your phone rooted?
If yes, you need a file explorer or file manager like ES File Explorer , or any app like that to find and delete the app .odex file ...
PinkLeviosa<3
Im just tryin' to help , so I hope it works
Sent from my SM-T210 using Tapatalk
re:samsung gt-19100
pinkLeviosa said:
Is your phone rooted?
If yes, you need a file explorer or file manager like ES File Explorer , or any app like that to find and delete the app .odex file ...
PinkLeviosa<3
Im just tryin' to help , so I hope it works
Sent from my SM-T210 using Tapatalk
Click to expand...
Click to collapse
Hi PinkLeviosa, Thank you so much for taking the time to reply to my post. The information you give doesn't register with me only because I don't understand your question "Is your phone rooted" or "file manager like ES File Explorer" I`m so sorry for not understanding this term please forgive me. Could you please explain in more simple terms. I feel I am in need of step to step instructions "doh" Thank You. Paul.
keo2458 said:
Hi PinkLeviosa, Thank you so much for taking the time to reply to my post. The information you give doesn't register with me only because I don't understand your question "Is your phone rooted" or "file manager like ES File Explorer" I`m so sorry for not understanding this term please forgive me. Could you please explain in more simple terms. I feel I am in need of step to step instructions "doh" Thank You. Paul.
Click to expand...
Click to collapse
So, I see.. If you know jailbreaking in apple products, you already know rooting, but they have some differences, please take time to read here
https://answers.yahoo.com/question/index?qid=20130510152416AAdgd1B
ES File Explorer is a File manager it helps you to move,paste,open files such as .zip , delete files like .odex ... and at the same time its a Root Explorer, Provides access to the entire file system and all data directories, and allows the user to change permissions. You can only unlock its feature like root explorer if your phone is rooted, for more details in ES file manager look here: https://play.google.com/store/apps/details?id=com.estrongs.android.pop
So if you dont know what root is, but now you know, the chances are your phone is not rooted... so i think you cant do your process of deleting the app's .odex but if you please can you try this app i found while searching your problem but it moves the cache of google play store at your sd card and no root is needed... the link: https://play.google.com/store/apps/details?id=net.felipearon.marketfix
and one more thing try to clear the cache of your google play store, if still that one dont work, try this:
http://forum.xda-developers.com/showthread.php?t=2443267 , but i think it needs a root access..
PS: remember use the search button before asking, XDA is your friend as well google:fingers-crossed:
re:samsung gt-19100
pinkLeviosa said:
So, I see.. If you know jailbreaking in apple products, you already know rooting, but they have some differences, please take time to read here
https://answers.yahoo.com/question/index?qid=20130510152416AAdgd1B
ES File Explorer is a File manager it helps you to move,paste,open files such as .zip , delete files like .odex ... and at the same time its a Root Explorer, Provides access to the entire file system and all data directories, and allows the user to change permissions. You can only unlock its feature like root explorer if your phone is rooted, for more details in ES file manager look here: https://play.google.com/store/apps/details?id=com.estrongs.android.pop
So if you dont know what root is, but now you know, the chances are your phone is not rooted... so i think you cant do your process of deleting the app's .odex but if you please can you try this app i found while searching your problem but it moves the cache of google play store at your sd card and no root is needed... the link: https://play.google.com/store/apps/details?id=net.felipearon.marketfix
and one more thing try to clear the cache of your google play store, if still that one dont work, try this:
http://forum.xda-developers.com/showthread.php?t=2443267 , but i think it needs a root access..
PS: remember use the search button before asking, XDA is your friend as well google:fingers-crossed:
Click to expand...
Click to collapse
Hi Again, Just wanted to thank you for taking the time to explain I have read the techo details and to be honest don't really understand so I am now going to admit defeat ha but a HUGE thank you for the effort in trying to explain. Time is precious and you spent a lot of time looking up details and to explain to me and for that I am really appreciative in all you have done. I came across this link which seemed to of worked ie I can now download a choice of apps without the dreaded "Insufficient Storage" Heres the link may just help someone. Once again a Big Thank you to you PinkLeviosa. https://www.youtube.com/watch?v=_RbCM8MOUVY
Haha... No problem!
Sent from my SM-T210 using Tapatalk

Question: Link2SD symbolic links after unroot?

Hi guys,
I noticed this question asked once before but it had no replies so hoping my thread might catch an answer.
I am unable to permanently root my device, but temporary (until restart) is possible. Does anyone know if I were to use Link2SD to create a symbolic link for an app, then restart (unroot), would the symbolic link still be in place and functional even without the root permissions for Link2SD?
Thanks for your attention on this!

Need step by step instructions how to automatically add files to the APK in Android Studio

I am trying to do this very trivial task, but I cannot find any complete instructions on how to do it.
So far, I gathered that
APK is just an archive that files can be added to using aapt add MyApp.apk file1 file2 ...
Or the files must be added to the assets folder
The APK must be less than 100mb to be allowed on the APP store
The files must be signed
The problem is that I am finding these one-line answers in Stack Overflow questions, and not in any official instructions from Android Studio developers, and they leave a lot of necessary steps out. Which I have to guess, like where to put the files, where are they getting stored on the device. If adding files to the assets folder, I need to know Which assets folder? app/build/intermediate? Do I need to add something to Gradle scripts? Are there any other steps?
This is a very basic thing that probably every android app needs to do, and I am baffled that there is not an option or support in the IDE to import and sign the files being used by the application.
So far I had to resort to manually uploading these files (YOLO ONNX models, label text files, test images, etc) to my phone and the emulator for testing.
I am looking for some clear and concise step by step instructions to how someone can add something like a text or image file to their APK, sign it, and make it deploy to the phone or emulator automatically when building, running, or debugging the app.
Can someone please help point me to such a resource?
Thank you,
dmitryengr said:
I am trying to do this very trivial task, but I cannot find any complete instructions on how to do it.
So far, I gathered that
APK is just an archive that files can be added to using aapt add MyApp.apk file1 file2 ...
Or the files must be added to the assets folder
The APK must be less than 100mb to be allowed on the APP store
The files must be signed
The problem is that I am finding these one-line answers in Stack Overflow questions, and not in any official instructions from Android Studio developers, and they leave a lot of necessary steps out. Which I have to guess, like where to put the files, where are they getting stored on the device. If adding files to the assets folder, I need to know Which assets folder? app/build/intermediate? Do I need to add something to Gradle scripts? Are there any other steps?
This is a very basic thing that probably every android app needs to do, and I am baffled that there is not an option or support in the IDE to import and sign the files being used by the application.
So far I had to resort to manually uploading these files (YOLO ONNX models, label text files, test images, etc) to my phone and the emulator for testing.
I am looking for some clear and concise step by step instructions to how someone can add something like a text or image file to their APK, sign it, and make it deploy to the phone or emulator automatically when building, running, or debugging the app.
Can someone please help point me to such a resource?
Thank you,
Click to expand...
Click to collapse
Hello and good afternoon, @dmitryengr
Welcome to XDA! I hope you'll always get the support you require.
However, prior to your next posting please read the guidances that are stuck on top of every forum like
Note: Questions go in Q&A Forum
If you are posting a Question Thread post it in the Q&A forum. Technical discussion of Android development and hacking. No noobs, please. Device-specific releases should go under the appropriate device forum...
forum.xda-developers.com
and the others. I've moved your thread to Android Q&A.
Thanks for your cooperation!
Regards
Oswald Boelcke
Senior Moderator

Categories

Resources