i want to do my Home app,and put it to /system dir,and my home app is the Unique home.of course i custom made my home app,and modify android source. all is ok. but i have a question, how to auto update my home app,i donot want to :
adb root
adb remount
adb shell rm /system/app/your.apk
adb push your.apk /system/app
if i can do it like common app update like:
download apk and
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
mContext.startActivity(intent);
or modify android source. can someone give me advice?
You can use the "common app update" method, or install the apk silently using android.permission.INSTALL_PACKAGES.
Either way your /system/app/whatever.apk is untouched, as it is not possible to change it without root (and the remount thing you mention in the question). Instead, the updated apk will get stored as /data/app/whatever.apk which will replace your system app. You can still use system app features.
The user can remove the updated apk ("uninstall updates") similar to regular, non-system apps, in that case, your original system apk is used again.
Related
I have copied my app into /system/priv-app/ and rebooted the system. The app no longer appears under Downloaded Apps, but now under System Apps. However, this only happens when I do not remove the original copy of the app under /data/app/. If I do remove the original copy under /data/app/ and reboot, the app does not show up anywhere at all, even though there is a copy of it under /system/priv-app/. Additionally, I verified with getPackageManager().getApplicationInfo(getPackageName(), 0).sourceDir that when the app does run (if I still have a copy in /data/app/), it is running from the non-privileged directory, even though I start it from under System Apps.
My permissions and ownership are all in line with all of the other apps in the /system/priv-app/ directory:
drwxr-xr-x root root
I found some related stackoverflow questions in which it is said to be sometimes necessary to run chcon on the APK after copying to /system/priv-app/. My system emits and error message "Could not label [my path] with u:object_r:app_data_file:s0: Operation not supported on transport endpoint". I discovered some documentation which said, "You are limited to changing the context of files whose partition is formatted with the ext4 file system. Any attempt to change the context of a file on another system results in the [error message I got]." So obviously chcon is not the solution in my case.
I'd be grateful for any tips on getting my app to show up under System Apps and run from the /system/priv-app/ directory.
Thanks!
EDITED TO ADD: I also signed my APK with the system key that has been used for key system apps. This also had no effect.
It turns out that I needed to first uninstall the package using from its original location using the Android package manager before the app could be picked up by the system to install. Previously, I had simply removed it on the command line from its original location. This time, I copied the files from /data/app/ to /system/priv-app/, ran pm uninstall [my package name], and rebooted. The program was successfully installed when the system came back up.
I made a filemanager that I want go be able to navegate/modify some system folders (say, /data/). I copied my apk to /system/app, gave 644 permission to the apk file, and rebooted. Yet, my app is still run without root privileges (deny simple access to /data). I'm using Cyanogenmod 11.
Any clue?
Thanks!
L.
To clarify, the app being in the /system/app folder does not run it as root. Android is linux based, so having root access means that your app is able to run shell commands as the root user.
Generally speaking an app being in the /system/app folder makes all declared permissions available to it, (for example, declaring WRITE_SECURE_SETTINGS only does anything for system apps), and then the code that was only available to system apps is now available to yours as well.
For reliability, you should use shell commands where possible for anything that's normally unavailable. Do not use java.io.File to access files that are normally restricted.
I would recommend using RootTools as it makes running shell commands as root much easier. The first 3 pages on this linux command cheat sheet will probably cover everything you need.
I try to understand how this works:
When I create an android app and run it from Eclipse, Eclipse takes care of generating the apk file and uses adb to install it on the phone correct?
When I have an .apk file that I try to push on the phone and use ADB directly in a command line by calling adb install myApp.apk I can't because my phone isn't rooted?
How does Eclipse manages to install apps then?
Is there a way to install from an .apk file on a device without having it rooted ? Obviously Eclipse is able to.
Thanks for any information that may help clarifying this.
David
So the really short answer to your question; You don't need to be rooted to use ADB, all android phones can use ADB without being rooted.
Also, the only reason you would need root is to mess with things on the system level, when installing a regular app you are just installing it like a regular application (to the data partition). Eclipse installs the app using ADB actually, so pushing an app using ADB is the same as installing it through eclipse.
You don't need to be rooted to use ADB, all android phones can use ADB without being rooted. You must be rooted to push applications to /system/apps/ to make them system applications. Also if you download a file explorer like ES File Explorer to your phone, you can transfer an apk file to your phones storage and using a file explorer (I really do recommend ES File Explorer) you can install that app.
Also just a tip, to use ADB command line you must enable ADB on your phone in developer settings.
Go to the settings menu, and scroll down to "About phone." Tap it.
Scroll down to the bottom again, where you see "Build number."
Tap it seven (7) times. After the third tap, you'll see a dialog that says you're four taps away from being a developer. Keep on tapping and the developer settings will show up in the settings app. There you can turn on ADB.
Hope this helps.
Further Reading: http://developer.android.com/tools/help/adb.html
http://www.androidcentral.com/how-enable-developer-settings-android-42
I have checked all the solutions, comments and answers of all other questions in StackOverflow.
I have been running, compiling and debugging my app for months. But suddenly it started to appear this message in my Eclipse when using my Nexus to play with it.
MOBILE:
I have no root !!! (It's a Nexus, and I have no root, and all the answers in other Stackoverflow's questions need root to be executed)
The application is uninstalled, there's no trace of it in "Applications"
Since I don't have root access, I can not access to /data/data folder, or /data/local, or /data
I do know problem would be solved resetting the phone to factory settings, but, sincerely, I can not.
ECLIPSE:
I have cleaned the project many times, restart Eclipse and even update it
I can not change the name of the project (as one solution suggests), since it's a long time project and I can not change it
Console says:
Installation error: INSTALL_FAILED_UID_CHANGED
Please check logcat output for more details.
Launch canceled!
Logcat says:
01-05 12:18:19.265: W/ActivityManager(761): No content provider found for permission revoke: file:///data/local/tmp/MyApp.apk
01-05 12:18:20.855: W/PackageManager(761): Package couldn't be installed in /data/app/com.myapp-1.apk
I can install, uninstall other APK/applications with no problems at all. So it's not about permissions in /data folder/subfolders
CONSOLE:
If I try to uninstall (with -d or any other parameter) the app it says: "Failure" (because adb does not find the app in the phone)
So, I'm not debugging with virtual machine / emulator. I have a Nexus no-rooted with no trace of the application, and I can not build the app from Eclipse to the device.
Thank you
I had the same issue in my non-rooted Nexus 5. I managed to solve it without root access nor Factory reset.
For this device, I managed to solve it by going to Settings -> Storage -> Misc and try to delete any files related to the faulty app (in my case, an .apk that was pushed from Android Studio and a .db file). I also clicked on Cached data to wipe the cache for all apps.
I don't know exactly which of the two things triggered the solution. You probably want to try to delete some files in Misc before wiping the cached data, since it seems less of an overkill.
It seems to be that there were some remaining files from a previous installation which weren't wiped with the uninstall (probably an issue in the Android installation system). These files aren't accessible without root access, since they are under the /data/local/ folder. Apparently the Storage tools for the Nexus 5 have permission to delete files under that folder.
I don't know whether other devices have a similar set of storage tools.
Downloading app from play store will resolve the issue.
To continue development on the app, uninstall the currently installed app and just launch the app from eclipse.
It works fine.
This may seem odd, but my pointy-haired boss just had this issue and tried everything we could think of. Just would NOT install due to the INSTALL_FAILED_UID_CHANGED error.
He uninstalled some other apps (games) and suddenly it would install. Maybe it is an issue of disk space on internal card? Dunno, but worth a try when someone else hits it.
First time this happened I tried installing from eclipse, from command line etc....
Everything failed so I did a factory reset which then worked.
24 hours later it happened again.
Not wanting to do another factory reset, I tried all the same things again to no avail.
Lastly I tried downloading our current app from the appstore, which miraculously worked.
I then used adb to reinstall.
So if you have a version of your app in the app store, try installing that to get something on your phone, then do a reinstall "adb -d install -r $PACKAGE.apk
Hope this helps someone.
This (or some other magic) helped me:
adb shell pm clear MY_PACKAGE_NAME
I can solve this like below without rooting on my Nexus 5.
Push your app to /sdcard/
adb push test.apk /sdcard/
adb shell
adb shell pm install -l /sdcard/test.apk
-l option means - pm install: installs a package to the system. Options:
-l: install the package with FORWARD_LOCK.
Here are some other things to check/try that are safe to do:
Make sure your package name is 100% unique and not colliding with
another app. You could temporarily change it to test.
Try powering your phone off and then back on to clear
data caches.
Try a soft reset for your device (which might be the
same as powering off/on).
Try deleting Cached Data under Settings -> Storage, this will clear all cached App data at once, but it does the job (in my case)
This is because of if you have install the app with same package name. So try to remove that one.
I could only fix this by rooting. I know you don't want to do that, but it worked for me. I downloaded Titanium Backup then found my uninstalled app crossed out in the list on Titanium Backup. I couldn't get rid of that crossed out one until I went to Batch Actions then Remove orphan data. That allowed me to re-install my app and it worked well.
This worked for me:
adb install -l -r <'apk_name'>.apk
-l = forward lock
-r = reinstall
I had this exact same problem. What finally worked for me was to change the applicationId (your package name) in build.gradle to something different, then rebuild the project, and voilà, successful deployment.
What led to this situation was that I'd copied an existing Android Studio project into a new one, and was working off of that new one. The thing is, I'd never deployed the original apk on my device before, and was only trying to deploy the new copy of the app.
I was using a device that was just for testing, so I just reset the whole device. It worked for me anywho.
This solution worked for me:
Put your APK to the device's storage/sd card
adb shell pm install -l -r "/sdcard/<apk_filename>.apk"
-l = forward lock
-r = reinstall
For no root Device you need you need to delete the app from the app list in the device:
go to "settings"
go to "storage"
on third tab "downloaded apps" locate your app
you can delete it from there
Works for me!
In my case changing the package name of the GCM signature worked. since it uninstalls the complete package.
For more detailed explination click here
<permission
android:name="com.androidcodelab.sampleproject.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.androidcodelab.sampleproject.permission.C2D_MESSAGE"/>
Package name of the project changed to :
<permission
android:name="com.androidcodelab.xyz.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.androidcodelab.xyz.permission.C2D_MESSAGE"/>
and then I reverted back to the actual package name
For android studio go to File-> Project Structure -> app -> Flavors and your right side you will see Application Id field just change Application Id and you are ready to go... :)
Go to Run/debug configurations.
Under Android App delete "app".
Then add another configuration under module: app
For me the only way was to root the phone and clear /data/data/ directory. Here are the steps:
1. Open web browser on mobile device
2. Open website: https://towelroot.com/
3. Click on lambda sign to download Towerl Root and install it afterwards
4. Open Towel root app and click on button "make it rain". If it says: "device not compatible" google other wait to root the device.
5. Download SuperSU app from Play Store
6. Download Terminal Emulator app from Play Store
7. Run Terminal Emulator
8. Type following command in terminal emulator:
su
9. Allow superuser access for terminal emulator
10.Type following command in terminal emulator, substitute 'package_name' with your app's package name:
rm -r /data/data/package_name
I tried all above and NADA!
the ONLY way it works for me (NON ROOTED DEVICE) was:
1.- Change on Project structure [Ctrl+Alt+Shift+S]->Flavors: the Application Id, for example:
'com.example.something' to 'com.example.somethingxx'.
(which is the same as changing on the build.gradle file)
2.- Refactor package name of the project to the SAME NEW NAME you used on Application Id: 'com.example.somethingxx'
This will ensure you are installing a new App on the device... let me know!
After android installs an application from the Marketplace, does it keep the .apk file?
Is there a standard location where Android would keep such files?
You can use package manager (pm) over adb shell to list packages:
adb shell pm list packages | sort
and to display where the .apk file is:
adb shell pm path com.king.candycrushsaga
package:/data/app/com.king.candycrushsaga-1/base.apk
And adb pull to download the apk.
adb pull data/app/com.king.candycrushsaga-1/base.apk
Preinstalled applications are in /system/app folder. User installed applications are in /data/app. I guess you can't access unless you have a rooted phone.
I don't have a rooted phone here but try this code out:
public class Testing extends Activity {
private static final String TAG = "TEST";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
File appsDir = new File("/data/app");
String[] files = appsDir.list();
for (int i = 0 ; i < files.length ; i++ ) {
Log.d(TAG, "File: "+files[i]);
}
}
It does lists the apks in my rooted htc magic and in the emu.
If you just want to get an APK file of something you previously installed, do this:
Get AirDroid from Google Play
Access your phone using AirDroid from your PC web browser
Go to Apps and select the installed app
Click the "download" button to download the APK version of this app from your phone
You don't need to root your phone, use adb, or write anything.
There is no standard location, however you can use the PackageManager to find out about packages and the ApplicationInfo class you can get from there has various information about a particular package: the path to its .apk, the path to its data directory, the path to a resource-only .apk (for forward locked apps), etc. Note that you may or may not have permission to read these directories depending on your relationship with the other app; however, all apps are able to read the resource .apk (which is also the real .apk for non-forward-locked app).
If you are just poking around in the shell, currently non-forward-locked apps are located in /data/app/.apk. The shell user can read a specific .apk, though it can't list the directory. In a future release the naming convention will be changed slightly, so don't count on it remaining the same, but if you get the path of the .apk from the package manager then you can use it in the shell.
Preinstalled Apps are typically in /system/app and user installed apps are in /data/app.
You can use "adb pull", but you need to know the full path of the APK file. On the emulator, you can get a directory listing using "adb shell" + "ls". But on an android device, you will not be able to do that in "/data" folder due to security reasons. So how do you figure out the full path of the APK file?
You can get a full list of all apps installed by writing a program that queries the PackageManager. Short code snippet below:
PackageManager pm = getPackageManager();
List<PackageInfo> pkginfo_list = pm.getInstalledPackages(PackageManager.GET_ACTIVITIES);
List<ApplicationInfo> appinfo_list = pm.getInstalledApplications(0);
for (int x=0; x < pkginfo_list.size(); x++){
PackageInfo pkginfo = pkginfo_list.get(x);
pkg_path[x] = appinfo_list.get(x).publicSourceDir; //store package path in array
}
You can also find apps that will give such info. There are lots of them. Try this one (AppSender).
Install from marketplace
It's the behavior of marketplace whether to keep the apk after installation. Google play doesn't keep the apk after the installation. Other third-party marketplaces might have the different behaviors.
Install from development/debug tool (adb, eclipse, android studio)
When we install the apk from debug tool, directly invoke adb install or from eclipse/android studio, the apk will be transferred (adb push) to a public read and writable directory, usually /data/local/tmp/. After that, the tool will use the pm command to install, it will delete the temporary apk in /data/local/tmp/ after the successful installation.
We could get these information from debug output like following.
$ adb install bin/TestApplication.apk
3155 KB/s (843375 bytes in 0.260s)
pkg: /data/local/tmp/TestApplication.apk
Success
How system keeps the apk
Of course the system have to store all apks somewhere. There are three places for the system to keep the apks based on the different types of apks:
for stock app
Those are usually shipped in device by manufacture, including core app for system running and google service, you can find them under directory /system/app and /system/priv-app.
user installed app
Most of the apks fall into this category. These apks are usually installed from marketplace by users or by adb install without -s option. You can find them under the directory /data/app for a rooted device.
app on sdcard
If the apk enable its install location in sdcard with android:installLocation="auto" in its manifest, the app can be moved to sdcard from system's app manager menu. These apks are usually located in secure folder of sdcard /mnt/sdcard/asec.
Anther way to force the install location to sdcard is using the command adb install -s apk-to-install.apk.
As a note, the files for pre-installed app are not in a single .apk file anymore. There is a folder containing files for every pre-installed app in the directory /system/app or /system/priv-app for the newest android release.
If you're looking for the path of a specific app, a quick and dirty solution is to just grep the bugreport:
$ adb bugreport | grep 'dir=/data/app'
I don't know that this will provide an exhaustive list, so it may help to run the app first.
You can pull apps with ADB. They are in /data/App/, I believe.
adb pull (location on device) (where to save)
Note that you have to root your phone to pull copy protected apps.
In /data/app but for copy protection I don't think you can access it.
If you are rooted, download the app Root Explorer. Best File manager for rooted users.
Anyways, System/app has all the default apks that came with the phone, and data/apk has all the apks of the apps you have installed. Just long press on the apk you want (while in Root Explorer), get to your /sdcard folder and just paste.
data/app
system/app
system/priv-app
mnt/asec (when installed in sdcard)
You can pull the .apks from any of them:
adb pull /mnt/asec
Use this to list all .apks under /data/app/
adb bugreport | grep 'package name="' | grep 'codePath="/data' | cut -d'"' -f4
.apk files can be located under /data/app/ directory. Using ES File Explorer we can access these .APK files.
if you are using eclipse goto DDMS and then file explorer there you will see System/Apps folder and the apks are there
When i installed my app on emulator, it showed my the .apk file in
data/app
Then I used
ls data/app //to see if it exists or
not
After you install your app just use ls command vie shell and check desired directory but it depends what kind of application you are trying to install. I used this method to Install
Point if any thing is wrong.
Another way to get the apks you can't find, on a rooted device is with rom tool box.
Make a backup using app manager then go to storage/emulated/appmanager and check either system app backup or user app backup.
To find an apk, download and Install the Bluetooth App Sender from Play store. Once installation completes open the Bluetooth App Sender. It will show all the apps (.apk) installed in your device, then you can easily transfer the app to your PC through Bluetooth.
As opposed to what's written on the chosen answer, you don't need root and it is possible to get the APKs of the installed apps, which is how I've done it on my app (here). Example:
List<PackageInfo> packages=getPackageManager().getInstalledPackages(0);
Then, for each of the items of the list, you can access packageInfo.applicationInfo.sourceDir, which is the full path of the APK of the installed app.
Install Total Commander.
Open Installed apps on the main page.
Well I came to this post because I wanted to reinstall some app I liked much.
If this is your case, just go to Google Play, and look for My Apps, the tab All, and you will find a way to reinstall some app you liked. I faced a problem that I could not find by search one app, but it was there in My apps so I could reinstall in my new mobile ;)