IT

Android는 .apk 파일을 유지합니까?

lottoking 2020. 5. 21. 08:28
반응형

Android는 .apk 파일을 유지합니까? 그렇다면 어디?


Android가 Marketplace에서 애플리케이션을 설치 한 후 .apk 파일을 유지합니까?

Android가 그러한 파일을 보관할 표준 위치가 있습니까?


사전 설치된 응용 프로그램은 /system/app폴더에 있습니다. 사용자 설치 응용 프로그램은에 /data/app있습니다. 루팅 된 전화가 없으면 액세스 할 수 없습니다. 루팅 된 전화는 없지만이 코드를 사용해보십시오.

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]);

        }
    }

그것은 내 뿌리 HTC 마술과 에뮤에 APK를 나열합니다.


패키지 관리자 ( pm)를 사용하여 패키지 adb shell를 나열 할 수 있습니다 .

adb shell pm list packages | sort

.apk파일이 있는 위치를 표시 합니다.

adb shell pm path com.king.candycrushsaga
package:/data/app/com.king.candycrushsaga-1/base.apk

그리고 adb pullAPK를 다운로드합니다.

adb pull data/app/com.king.candycrushsaga-1/base.apk

이전에 설치 한 것의 APK 파일을 얻으려면 다음을 수행하십시오.

  1. Google Play에서 AirDroid 받기
  2. PC 웹 브라우저에서 AirDroid를 사용하여 휴대폰에 액세스
  3. 앱으로 이동하여 설치된 앱을 선택하십시오.
  4. 휴대 전화에서이 앱의 APK 버전을 다운로드하려면 "다운로드"버튼을 클릭하십시오

휴대 전화를 근절하거나을 사용 adb하거나 아무 것도 쓰지 않아도됩니다 .


표준 위치는 없지만 PackageManager를 사용하여 패키지를 찾을 수 있으며 여기에서 얻을 수있는 ApplicationInfo 클래스에는 특정 패키지에 대한 다양한 정보가 있습니다. .apk 경로, 데이터 디렉토리 경로, 경로 리소스 전용 .apk (포워드 잠금 앱의 경우) 등으로 전달합니다. 다른 앱과의 관계에 따라이 디렉토리를 읽을 권한이 있거나 없을 수 있습니다. 그러나 모든 앱은 리소스 .apk (앞으로 잠그지 않은 앱의 실제 .apk)를 읽을 수 있습니다.

셸에서 방금 파고 드는 경우 현재 전달되지 않은 앱은 /data/app/.apk에 있습니다. 쉘 사용자는 디렉토리를 나열 할 수 없지만 특정 .apk를 읽을 수 있습니다. 다음 릴리스에서는 이름 지정 규칙이 약간 변경되므로 동일하게 유지되지는 않지만 패키지 관리자에서 .apk 경로를 얻으면 셸에서 사용할 수 있습니다.


사전 설치된 앱은 일반적으로 / system / app에 있고 사용자 설치 앱은 / data / app에 있습니다.

"adb pull"을 사용할 수 있지만 APK 파일의 전체 경로를 알아야합니다. 에뮬레이터에서 "adb shell"+ "ls"를 사용하여 디렉토리 목록을 얻을 수 있습니다. 그러나 Android 기기에서는 보안상의 이유로 "/ data"폴더에서이를 수행 할 수 없습니다. APK 파일의 전체 경로를 어떻게 알 수 있습니까?

PackageManager를 쿼리하는 프로그램을 작성하여 설치된 모든 앱의 전체 목록을 얻을 수 있습니다. 아래의 짧은 코드 스 니펫 :

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
}

그러한 정보를 제공 할 앱을 찾을 수도 있습니다. 그것들이 많이 있습니다. 이것을 사용해보십시오 (AppSender).


특정 앱의 경로를 찾고 있다면 버그 리포트를 grep하는 것이 빠르고 더러운 해결책입니다.

$ adb bugreport | grep 'dir=/data/app' 

이것이 완전한 목록을 제공한다는 것을 모르므로 앱을 먼저 실행하는 데 도움이 될 수 있습니다.


ADB로 앱을 가져올 수 있습니다. 그들은 / data / App /에 있다고 생각합니다.

adb pull (location on device) (where to save)

복사 방지 된 앱을 가져 오려면 휴대 전화를 루팅해야합니다.


마켓 플레이스에서 설치

설치 후 APK를 유지할지 여부는 마켓 플레이스의 동작입니다. Google Play는 설치 후 APK를 유지하지 않습니다. 다른 타사 마켓 플레이스에는 다른 동작이있을 수 있습니다.

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 basic on the different types of apks.

  1. 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.

  1. 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.

  1. 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.


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.


Use this to list all .apks under /data/app/

adb bugreport | grep 'package name="' | grep 'codePath="/data' | cut -d'"' -f4

  • 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


.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.


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 ;)

참고URL : https://stackoverflow.com/questions/2507960/does-android-keep-the-apk-files-if-so-where

반응형