csdnceshi62
csdnceshi62
采纳率100%
2010-08-13 19:43

如何在 Android 模拟器中安装 APK 文件?

I finally managed to obfuscate my Android application, now I want to test it by installing the APK file and running it on the emulator.

How can I install an APK file on the Android Emulator?

转载于:https://stackoverflow.com/questions/3480201/how-do-you-install-an-apk-file-in-the-android-emulator

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

30条回答

  • csdnceshi66 必承其重 | 欲带皇冠 11年前

    You can simply drag and drop the .apk file of your application to the emulator and it will automatically starts installing.

    Another options:


    Windows:

    1. Execute the emulator (SDK Manager.exe->Tools->Manage AVDs...->New then Start)
    2. Start the console (Windows XP), Run -> type cmd, and move to the platform-tools folder of SDK directory.
    3. Paste the APK file in the 'android-sdk\tools' or 'platform-tools' folder.
    4. Then type the following command.

      adb install [.apk path]

      Example:

      adb install C:\Users\Name\MyProject\build\Jorgesys.apk

    Linux:

    1. Copy the apk file to platform-tools in android-sdk linux folder.
    2. Open Terminal and navigate to platform-tools folder in android-sdk.
    3. Then Execute this command -

      ./adb install FileName.apk

    4. If the operation is successful (the result is displayed on the screen), then you will find your file in the launcher of your emulator.

    Mac:

    PATH=$PATH:~/Library/Android/sdk/platform-tools
    

    Example : PATH=$PATH:/users/jorgesys/eclipse/android-sdk-mac_64/tools

    Then run adb.

    Mac:

    1.Run the emulator,

    2.then copy your .apk file and paste into /Users/your_system_username/Library/Android/sdk/platform-tools,
    if you are not able to find sdk path in your mac system, do the following steps: Open finder->select Go option on top menu -> select Go to Folder option -> it will popup a window with a textfield: /Users/your_system_username/Library/Android/sdk/ -> now open platform-tools folder and paste your copied .apk file,

    1. Now open terminal and type the following: cd Library/Android/sdk/platform-tools

    2. execute the following in your terminal: ./adb install yourapkfilename.apk if you get the following error message: error: no devices found - waiting for device, follow the step 5.

    3. Run your emulator from Android Studio, once emulator active then repeat step 4, you will see the success message on your terminal.

    点赞 30 评论 复制链接分享
  • weixin_41568208 北城已荒凉 4年前

    Just drag and drop apk file in the emulator and done....

    点赞 评论 复制链接分享
  • csdnceshi62 csdnceshi62 5年前

    Simple You can upload APK to file hosting or download APK and use browser to install from unknown source .

    点赞 评论 复制链接分享
  • csdnceshi75 衫裤跑路 5年前

    Start the console (Windows XP), Run -> type cmd, and move to the platform-tools folder of SDK directory.

    In case anyone wondering how to run cmd in platform-tools folder of SDK directory, if you are running a new enough version of Windows, follow the steps:

    1. Go to platform-tools through Windows Explorer.
    2. While holding shift right click and you will find the option "Open Command window here".
    3. Click on it and cmd will start in that folder.

    enter image description here

    Hope it helps

    点赞 评论 复制链接分享
  • csdnceshi62 csdnceshi62 5年前

    1) paste the myapp.apk in platform-tools folder , in my case C:\Users\mazbizxam\AppData\Local\Android\android-sdk\platform-tools, this is the link in my case it may change to you people

    2)open the directory in CMD CD C:\Users\mazbizxam\AppData\Local\Android\android-sdk\platform-tools

    3)Now you are in platform-tools folder , just type adb install myapp.apk

    please ensure that your emulator is turn on , if every thing is ok apk will install

    点赞 评论 复制链接分享
  • csdnceshi62 csdnceshi62 3年前

    Drag and drop ".apk" file into the emulator window.

    点赞 2 评论 复制链接分享
  • csdnceshi63 elliott.david 5年前

    Follow the steps :

    1. make sure you have allowed installation from unknown sources in settings.
    2. Use the Android Device Monitor to copy the APK to the sdcard.
    3. Use the builtin browser in Android to navigate to file:///sdcard/apk-name.apk
    4. When the notification "Download complete" appears, click it.
    点赞 7 评论 复制链接分享
  • csdnceshi64 游.程 4年前

    On Linux I do this:

    1. first see which devices I currently have: emulator -list-avds
    2. build the release cd android && ./gradlew assembleRelease
    3. install it at the emulated device "Nexus5" (you are inside the android directory, else use the full path to apk): adb -s '8e138a9c' install app/build/outputs/apk/app-release.apk

    Thats it. You can also use ./gradlew installRelease

    点赞 4 评论 复制链接分享
  • csdnceshi60 ℡Wang Yan 4年前

    Now you can just drag and drop the apk in emulator and it will install!

    点赞 8 评论 复制链接分享
  • csdnceshi78 程序go 4年前

    In mac or windows . Just run the emulator and Drag and drop the apk on the home screen . It will install

    点赞 10 评论 复制链接分享
  • csdnceshi64 游.程 5年前

    Best way is to create a app, which opens the apk file on the emulator. You have to copy the .apk file to the download folder of your emulator. Then replace yourAppName.apk with your .apk name.

    here is the code

    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
    
    
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "yourAppName.apk")), "application/vnd.android.package-archive");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
    
    
        }
    }
    
    点赞 8 评论 复制链接分享
  • csdnceshi70 笑故挽风 6年前

    you write the command on terminal/cmd adb install FileName.apk.

    点赞 8 评论 复制链接分享
  • csdnceshi51 旧行李 7年前

    go to ADT/Android-sdk/tools directory in command prompt 1. adb install fileName.apk (Windows)

    1. ./adb install fileName.apk (Ubuntu/Linux or Mac)
    点赞 2 评论 复制链接分享
  • csdnceshi71 Memor.の 3年前

    First you need to install Android Studio on your machine. Then simply follow these steps.

    1. Go to you navigation bar and open Android Studio. enter image description here
    2. From the toolbar open AVD Manager. (If you cannot see it create a new android project) enter image description here
    3. Create a Virtual Device. enter image description here
    4. Select a hardware device that you want to install your app. enter image description here
    5. Select an android image that you want to install on your device. (If you cannot see any images you can download the require image from Recommended, x86 Images or Other images) enter image description here
    6. Add a name to your AVD. enter image description here
    7. Now the virtual device has been created and you can simply run it by clicking the play button. enter image description here
    8. Now you have setup the virtual device and now you need to install the APK file. enter image description here
    9. Download the APK file that you want to install and Drag and Drop it to the emulator. enter image description here
    10. The APK file has been successfully installed and you can see it in your applications. enter image description here
    11. Now you can simply run the installed app. enter image description here
    点赞 6 评论 复制链接分享
  • csdnceshi62 csdnceshi62 6年前

    if use more than one emulator at firs use this command

    adb devices
    

    and then chose amulatur and install application

    adb -s "EMULATOR NAME" install "FILE PATH"
    adb -s emulator-5556 install C:\Users\criss\youwave\WhatsApp.apk
    
    点赞 3 评论 复制链接分享
  • csdnceshi77 狐狸.fox 7年前

    keep your emulator up and running. In the command line, go inside the platform-tools folder, in your sdk folder which come with adt bundle and execute following command :

    >adb install <yourFilename.apk>
    

    This command detect your running emulator/emulators and show you the list of devices where you can install this app(show if any physical device/devices connected to your computer.). Then you can select any one, if only one emulator is running then app will directly installed on it by default.

    Note: For above command your .apk file needs to be in same directory.

    for more detailed tutorial follo : This link

    点赞 7 评论 复制链接分享
  • csdnceshi72 谁还没个明天 4年前

    I might be wrong, but on Windows I simply drag and drop the .apk into Android Emulator. I mean, doing all mentioned above seems to be a lot of work.

    点赞 4 评论 复制链接分享
  • csdnceshi77 狐狸.fox 7年前

    (TESTED ON MACOS)

    The first step is to run the emulator

    emulator -avd < avd_name>

    then use adb to install the .apk

    adb install < path to .apk file>

    If adb throws error like APK already exists or something alike. Run the adb shell while emulator is running

    adb shell

    cd data/app

    adb uninstall < apk file without using .apk>

    If adb and emulator are commands not found do following

    export PATH=$PATH://android-sdk-macosx/platform-tools://android-sdk-macosx/android-sdk-macosx/tools:

    For future use put the above line at the end of .bash_profile

    vi ~/.bash_profile

    点赞 4 评论 复制链接分享
  • csdnceshi70 笑故挽风 7年前

    From Windows 7 Onwards ,

    Shift + Right click in your apk file folder.

    Select Open Command Window Here

    Type & Hit "adb install AppName.apk"

    点赞 8 评论 复制链接分享
  • csdnceshi66 必承其重 | 欲带皇冠 8年前

    Download the Apk file from net and copy it to platform-tools of your SDK folder, then in command prompt go to that directory an type:

    adb install filename.apk
    

    press enter it will install in few seconds

    点赞 10 评论 复制链接分享
  • weixin_41568110 七度&光 5年前

    Drag and drop

    Simply drag-and-drop the apk file into your emulator.

    You can also run your android emulator without Android Studio.

    点赞 2 评论 复制链接分享
  • csdnceshi51 旧行李 8年前

    Let's suppose you have to install Facebook APK on your emulator.

    You can use adb to install the APK to the running emulator in OS X like this:

    ./adb install ~/FBAndroid-2.1.apk
    

    And on Windows, like this:

    adb install %HOMEPATH%\FBAndroid-2.1.apk
    

    Once complete, check the apps screen of the emulator to check that the app has been installed correctly. If you need to force the upgrade of this app from a previous version, add the -r flag, like this on OS X:

    ./adb install -r ~/FBAndroid-2.1.apk
    
    点赞 8 评论 复制链接分享
  • weixin_41568134 MAO-EYE 7年前

    In Genymotion just drag and drop the *.apk file in to the emulator and it will automatically installs and runs.

    http://www.genymotion.com/

    点赞 3 评论 复制链接分享
  • weixin_41568184 叼花硬汉 8年前

    Goto Shell/Terminal/, reach at android-sdk/tools directory then

    adb install fileName.apk // (u can run this command on windows)
    or 
    ./adb install fileName.apk  //( u can run this command on linux)
    
    点赞 10 评论 复制链接分享
  • csdnceshi62 csdnceshi62 9年前

    Download apk file from browser and then just click on it (notification area). Installation will start automatically.

    点赞 8 评论 复制链接分享
  • csdnceshi59 ℙℕℤℝ 7年前

    Copy .apk file in your SDK's platform-tools/ directory,then install the .apk on the emulator by using cmd(on windows):

    adb install <path_to_your_bin>.apk
    

    or

    ./adb install <path_to_your_bin>.apk
    

    If there is more than one emulator running, you can find all running emulators by this command:

    adb devices
    

    or

    ./adb devices
    

    then you must specify the emulator upon which to install the application, by its serial number, with the -s option. For example:

    adb -s emulator-5554 install path/to/your/app.apk
    

    or

    ./adb -s emulator-5554 install path/to/your/app.apk
    
    点赞 2 评论 复制链接分享
  • csdnceshi62 csdnceshi62 8年前

    go to the android-sdk/tools directory in command prompt and then type

     adb install fileName.apk (Windows)
    
     ./adb install fileName.apk (Linux or Mac)
    
    点赞 10 评论 复制链接分享
  • csdnceshi77 狐狸.fox 11年前
    go to sdk folder, then go to tools.
    copy your apk file inside the tool directory
    ./emulator -avd myEmulator
    to run the emulator on mac 
    ./adb install myApp.apk
    to install app on the emulator
    
    点赞 9 评论 复制链接分享
  • csdnceshi66 必承其重 | 欲带皇冠 5年前

    Nowadays, you can simply drag and drop the Android apk to the emulator and it will automatically starts installing.

    点赞 5 评论 复制链接分享
  • csdnceshi53 Lotus@ 10年前

    If you've created more than one emulators or if you have an Android device plugged in, adb will complain with

    error: more than one device and emulator
    

    adb help is not extremely clear on what to do:

    -d                        - directs command to the only connected USB device...
    -e                        - directs command to the only running emulator...
    -s <serial number>        ...
    -p <product name or path> ...
    

    The flag you decide to use has to come before the actual adb command:

    adb -e install path/to/app.apk
    
    点赞 29 评论 复制链接分享