Run android code on windows

Как запустить любое приложение Android в Windows 11

Microsoft сотрудничает с Amazon, чтобы реализовать интеграцию Amazon AppStore с Microsoft Store. На деле это означает, что вы не можете официально получить доступ к обширной библиотеке приложений в магазине Google Play. На данный момент для тестирования доступны даже не все приложения из Amazon AppStore. Инсайдеры могут протестировать лишь одобренные Microsoft и Amazon 50 избранных приложений.

К счастью, Microsoft сразу предусмотрела возможность отладки для Подсистемы Windows для Android. В результате вы можете получить доступ и отладку виртуального слоя Android в хост-системе Windows 11, используя инструмент Android Debugging Bridge (ADB). ADB можно использовать для установки любого стандартного пакета приложения Android (APK), в том числе для загрузки в подсистему приложений, которые отсутствуют в Amazon AppStore.

Итак, воспользуйтесь нашей инструкцией Как протестировать приложения Android на любом Windows 11 ПК, если вы не инсайдер и настройте Подсистему Windows для Android на своем компьютере Windows 11. Далее следуйте инструкциям, чтобы запустить свои любимые мобильные приложения.

Как установить в Подсистему Windows для Android любое приложения Android

Подсистема Windows для Android находится на стадии бета-тестирования. Приложения, одобренные Microsoft и Amazon, скорее всего, были дополнительно оптимизированы для подсистему, поэтому они обеспечили себе места в первой партии. Нет никаких гарантий, что другие приложения будут сразу работать корректно. Единственный способ проверить совместимость на практике — запустить приложение в Подсистеме Windows для Android.

Чтобы загрузить любое приложение для Android в подсистему Windows 11 для Android, выполните следующие действия:

  • Загрузите файл APK желаемого приложения или игры из доверенного источника.
    • Проекты, поддерживаемые сообществом доступны на сторонних форумах (XDA, 4PDA и др).
    • APK файлы приложений с открытым исходным кодом часто встречаются в репозиториях GitHub или на сторонних сайтах, таких как F-Droid.
    • Наконец, существует сторонние ресурсы с APK-файлами, например APK Mirror и APKPure.
  • После того, как вы заполучили файл APK, запустите среду Подсистемы Windows для Android. Перейдите в меню «Пуск» > Все приложения > Windows Subsystem for Android.
  • Откроются настройки подсистемы. Вам нужно активировать переключатель Режим разработчика.
  • Поскольку среда Android работает рядом с ядром хост-системы Windows, мы можем получить доступ к ней через интерфейс localhost (127.0.0.1). Фактически, слой Android также связывается со случайным IP из частной сети 172.30.0.0/24, которая видна под IP-адресом.
    • Если вы не можете увидеть IP-адрес в форме 172.30.x.x, нажмите на опцию Файлы в верхней части экрана настроек, чтобы перейти к файловой системе подсистемы во встроенном Проводнике. Затем нажмите кнопку Обновить напротив опции IP-адрес, чтобы получить IP-адрес. Теперь вы можете скопировать его одним нажатием кнопки.
  • Теперь мы можем подключиться с помощью ADB из хост-системы Windows 11. Вы можете использовать localhost (127.0.0.1) с портом 58526, либо IP-адресом, показанным в окне настроек, чтобы установить соединение.
  • Настройте ADB:
    • Откройте сайт ADB Installer и в разделе ADB and fastboot скачайте platform-tools для Windows.
    • Распакуйте скачанный архив и переместите папку platform-tools в удобное расположение. В нашем примере это будет C:\platform-tools
  • Откройте новое окно терминала Windows и перейдите в расположение ADB:
  • Далее введите одну из следующих команд:

(Вместо IP-адреса подставьте свой IP-адрес, полученный на предыдущем шаге).

  • Теперь можно установить наш APK через ADB. Команда должна быть следующей:
  • В нашем примере мы скачали apk-файл почтового клиента Spark на сайте Apk Mirror.
  • Если пройдет корректно, то ярлык приложения для Android будет создан в меню «Пуск». Нажмите на ярлык, чтобы запустить приложение.
  • Если вы не можете найти ярлык приложения Android, вы можете вручную запустить его, используя следующую команду:
  • Например, чтобы запустить приложение Spark, введите следующее в окно Выполнить в Windows:
  • Вы также можете вызвать приложение непосредственно из окна ADB Shell:
  • Чтобы запустить приложение Spark, команда должна быть:

Обратите внимание, что неофициальные приложения будут иметь доступ к сети. Таким образом, вы можете установить и использовать популярные мобильные браузеры внутри подсистемы Windows для Android, например Firefox. Браузеры можно использовать для загрузки других приложений. Windows 11 также позволяет применять правила брандмауэра для приложений Android. Хотя можно установить приложение, зависящее от Служб Google, оно не запуститься из-за их отсутствия. В качестве обходного варианта можно воспользоваться microG.

Также доступен относительно простой способ для обхода региональных ограничений для использования Amazon Appstore. При этом вам не нужно будет использовать VPN-сервис или изменять настройки региона в Windows 11. Вы можете еще больше «прокачать» подсистему Windows для Android, загрузив альтернативный клиент Google Play Store под названием Aurora Store.

Источник

How to Run Android Apps on Windows 10

Learn about running Android apps through Windows

What to Know

  • The easiest way is to use the Your Phone App from Microsoft.
  • However, this method actually runs the app from your phone and displays it on Windows rather than emulating Android on Windows.

If you want to ensure your files and data are easily accessible across devices, one way is to run the same apps on your PC as you do on your Android phone. Microsoft’s operating system has become increasingly Android-friendly, and we’ll show you how to use this to run apps from your Android device on your Windows 10 PC.

How Can I Run Android Apps on My PC?

There are two main ways to run Android apps on a Windows 10 machine.

  • You can use an Android emulator. This is an application which simulates an entire Android device (including both hardware and software), so the Android app will behave as if it’s on an Android device. Emulators allow you to install the app locally, so it’s always available, but they borrow a good amount of horsepower from your PC. If you feel like this is the approach for you, use the Bluestacks emulator to run Android apps on your PC.
  • The other option is to run the app from your phone, but display and interact with it through your PC. This has the advantage of not requiring complicated emulators, but it also requires your phone be linked to your PC while you’re using your apps.
Читайте также:  Vive le roi андроид

In this article, we’re only going to cover using Microsoft’s Your Phone app which allows you to interact with an Android phone via your PC. You can check out the emulation solution with the link above.

How Do I Run Android Apps on My Windows 10 Laptop?

These instructions require the following:

  • A Windows PC with at least the Windows 10 May 2020 Update installed.
  • An device running version 11.0 (or higher) of Android.
  • In addition, Microsoft recommends having at least 8 GB of RAM.

To run Android apps from your phone on Windows, take the following steps:

First, get the Your Phone app from Microsoft to install on your Windows 10 PC. Make sure the version you get is at least 1.20104.15.0.

Next, go to the Google Play store to get the Your Phone Companion app If you already have it installed, make sure it’s updated, as you’ll need at least version 1.20104.15.0 to access your apps.

You’ll need to link your Android device to your PC. Make sure they’re on the same network, then open the Your Phone app on the PC.

Click on the Get Started button.

Check the I have the companion app ready option if you installed the “My Phone” app as described in step 2. Otherwise the URL on this screen will take you straight to it.

Once it’s installed, you can easily pair your phone by clicking the Pair with QR Code button

Then, open the Link to Windows option in Android Settings, which will display a screen to confirm you are in fact seeing the QR Code. Tap Continue.

Finally, point your phone at the QR Code. Once the camera picks it up, the Windows app will show a screen explaining the permissions it requires.

On the phone, you can tap Allow to give Windows the permissions it needs as they come up. When you’re finished tap Continue, and the two devices are linked.

On the PC you’ll get a welcome screen showing your phone and PC are now linked; on the Android device, you may see an additional permission as shown in the below screenshot. You’ll need to accept this now, and it will also appear once each time you connect your devices. Click Start recording or casting with Your Phone Companion, which is what allows your phone to transmit its app (or entire screen) to the PC.

Select the Apps option in the left-hand panel.

This will display a list of apps installed on your phone. Click on the app you want, and it will launch in a window just as it looks on your device.

Alternately, you can use the Open Phone Screen link to open a window which mimics your device, home screen and all. You can open and interact with apps in this way as well.

Screen Mirror vs. App Launch

When opening apps in step 13, they will open within the “phone’s” window. However, when launching from the Apps screen in the Windows Your Phone app, they open in separate windows. This means you can multi-task by having multiple Android app windows open at once. You can also pin these apps to the Taskbar, just like any normal Windows app.

Connect your phone and PC with a USB cable and select Transfer files on your Android. On your PC, select Open device to view files > This PC. Alternatively, connect wirelessly via Bluetooth.

BlueStacks, Andy, Genymotion, Remix OS, and NoxPlayer are some of the most popular Android emulators for Windows. Android Studio from Google also has a built-in emulator.

No, but you can use Microsoft Launcher to access Windows apps from your Android phone or tablet. Microsoft Launcher customizes your phone’s look with Windows 10-style wallpapers, themes, and icons.

Yes, Windows 11 supports Android apps. You can purchase Android apps for Windows 11 through the Microsoft Store. You do not need an emulator to run them.

Источник

Build and run your app

Android Studio sets up new projects to deploy to the Android Emulator or a connected device with just a few clicks. Once your app is installed, you can use Apply Changes to deploy certain code and resource changes without building a new APK.

To build and run your app, follow these steps:

    In the toolbar, select your app from the run configurations drop-down menu.

From the target device drop-down menu, select the device that you want to run your app on.

If you don’t have any devices configured, then you need to either connect a device via USB or create an AVD to use the Android Emulator.

Click Run .

Change the run/debug configuration

When you run your app for the first time, Android Studio uses a default run configuration. The run configuration specifies whether to deploy your app from an APK or an Android App Bundle, the module to run, package to deploy, activity to start, target device, emulator settings, logcat options, and more.

The default run/debug configuration builds an APK, launches the default project activity, and uses the Select Deployment Target dialog for target device selection. If the default settings don’t suit your project or module, you can customize the run/debug configuration, or even create a new one, at the project, default, and module levels. To edit a run/debug configuration, select Run > Edit Configurations. For more information, see Create and Edit Run/Debug Configurations.

Change the build variant

By default, Android Studio builds the debug version of your app, which is intended for use only during development, when you click Run.

To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar.

For projects without native/C++ code, the Build Variants panel has two columns: Module and Active Build Variant. The Active Build Variant value for the module determines which build variant the IDE deploys to your connected device and is visible in the editor.

Figure 1. The Build Variants panel has two columns for projects that do not have native/C++ code

To switch between variants, click the Active Build Variant cell for a module and choose the desired variant from the list field.

For projects with native/C++ code, the Build Variants panel has three columns: Module, Active Build Variant, and Active ABI. The Active Build Variant value for the module determines the build variant that the IDE deploys to your device and is visible in the editor. For native modules, the Active ABI value determines the ABI that the editor uses, but does not impact what is deployed.

Читайте также:  Nba 2k playgrounds android

Figure 2. The Build Variants panel adds the Active ABI column for projects with native/C++ code

To change the build variant or ABI, click the cell for the Active Build Variant or Active ABI column and choose the desired variant or ABI from the list. After you change the selection, the IDE syncs your project automatically. Changing either column for an app or library module will apply the change to all dependent rows.

By default, new projects are set up with two build variants: a debug and release variant. You need to build the release variant to prepare your app for public release.

To build other variations of your app, each with different features or device requirements, you can define additional build variants.

Conflicts in Android Studio’s Build Variants dialog

In Android Studio’s Build Variants dialog, you might see error messages indicating conflicts between build variants, such as the following:

This error does not indicate a build issue with Gradle – it is only indicating that the Android Studio IDE itself cannot resolve symbols between the variants of the selected modules.

For example, if you have a module M1 that depends on variant v1 of module M2 , but M2 has variant v2 selected in the IDE, you have unresolved symbols in the IDE. Let’s say that M1 depends on a class Foo which is only available in v1 . When v2 is selected, that class is not known by the IDE and it will fail to resolve it and show errors in the code of M1 .

These error messages appear because the IDE cannot load code for multiple variants simultaneously. In terms of your app’s build, however, the variant selected in this dialog will have no effect because Gradle builds your app with the source code specified in your Gradle build recipes, not based on what’s currently loaded in the IDE.

Build your project

The Run button builds and deploys your app to a device. However, to build your app to share or upload to Google Play, you’ll need to use one of the options in the Build menu to compile parts or all of your project. Before you select any of the build options listed in table 1, make sure you first select the build variant you want to use.

Table 1. Build options in the Build menu.

Builds an APK of all modules in the current project for their selected variant. When the build completes, a confirmation notification appears, providing a link to the APK file and a link to analyze it in the APK Analyzer.

If the build variant you’ve selected is a debug build type, then the APK is signed with a debug key and it’s ready to install. If you’ve selected a release variant, then, by default, the APK is unsigned and you must manually sign the APK. Alternatively, you can select Build > Generate Signed Bundle / APK from the menu bar.

Android Studio saves the APKs you build in project-name / module-name /build/outputs/apk/ .

Builds an Android App Bundle of all modules in the current project for their selected variant. When the build completes, a confirmation notification appears, providing a link to the app bundle and a link to analyze it in the APK Analyzer.

If the build variant you’ve selected is a debug build type, then the app bundle is signed with a debug key, and you can use bundletool to deploy your app from the app bundle to a connected device. If you’ve selected a release variant, then the app bundle is unsigned by default and you must manually sign it using jarsigner . Alternatively, you can select Build > Generate Signed Bundle / APK from the menu bar.

Android Studio saves the APKs you build in project-name / module-name /build/outputs/bundle/ .

Menu Item Description
Make Module Compiles all source files in the selected module that have been modified since the last build, and all modules the selected module depends on recursively. The compilation includes dependent source files and any associated build tasks. You can select the module to build by selecting either the module name or one of its files in the Project window.
Make Project Makes all modules.
Clean Project Deletes all intermediate/cached build files.
Rebuild Project Runs Clean Project for the selected build variant and produces an APK.
Build Bundle(s) / APK(s) > Build APK(s)
Build Bundle(s) / APK(s) > Build Bundle(s)
Brings up a dialog with a wizard to set up a new signing configuration, and build either a signed app bundle or APK. You need to sign your app with a release key before you can upload it to the Play Console. For more information about app signing, see Sign your app.

Note: The Run button builds an APK with testOnly=»true» , which means the APK can only be installed via adb (which Android Studio uses). If you want a debuggable APK that people can install without adb, select your debug variant and click Build Bundle(s) / APK(s) > Build APK(s).

For details about the tasks that Gradle executes for each command, open the Build window as described in the next section. For more information about Gradle and the build process, see Configure Your Build.

Monitor the build process

You can view details about the build process by clicking View > Tool Windows > Build (or by clicking Build in the tool window bar). The window displays the tasks that Gradle executes in order to build your app, as shown in figure 3.

Figure 3. The Build output window in Android Studio

    Build tab: Displays the tasks Gradle executes as a tree, where each node represents either a build phase or a group of task dependencies. If you receive build-time or compile-time errors, inspect the tree and select an element to read the error output, as shown in figure 4.

Figure 4. Inspect the Build output window for error messages

  • Sync tab: Displays tasks that Gradle executes to sync with your project files. Similar to the Build tab, if you encounter a sync error, select elements in the tree to find more information about the error.
  • Restart: Performs the same action as selecting Build > Make Project by generating intermediate build files for all modules in your project.
  • Toggle view: Toggles between displaying task execution as a graphical tree and displaying more detailed text output from Gradle—this is the same output you see in the Gradle Console window on Android Studio 3.0 and earlier.
  • If your build variants use product flavors, Gradle also invokes tasks to build those product flavors. To view the list of all available build tasks, click View > Tool Windows > Gradle (or click Gradle in the tool window bar).

    If an error occurs during the build process, Gradle may recommend some command-line options to help you resolve the issue, such as —stacktrace or —debug . To use command-line options with your build process:

    1. Open the Settings or Preferences dialog:
      • On Windows or Linux, select File >Settings from the menu bar.
      • On Mac OSX, select Android Studio >Preferences from the menu bar.
    2. Navigate to Build, Execution, Deployment >Compiler.
    3. In the text field next to Command-line Options, enter your command-line options.
    4. Click OK to save and exit.

    Gradle applies these command-line options the next time you try building your app.

    Apply Changes

    In Android Studio 3.5 and higher, Apply Changes lets you push code and resource changes to your running app without restarting your app—and, in some cases, without restarting the current activity. This flexibility helps you control how much of your app is restarted when you want to deploy and test small, incremental changes while preserving your device’s current state. Apply Changes uses capabilities in the Android JVMTI implementation that are supported on devices running Android 8.0 (API level 26) or higher. To learn more about how Apply Changes works, see Android Studio Project Marble: Apply Changes.

    Requirements

    Apply Changes actions are only available when you meet the following conditions:

    • You build the APK of your app using a debug build variant.
    • You deploy your app to a target device or emulator that runs Android 8.0 (API level 26) or higher.

    Use Apply Changes

    Use the following options when you want to deploy your changes to a compatible device:

    Apply Changes and Restart Activity

    Attempts to apply both your resource and code changes by restarting your activity but without restarting your app. Generally, you can use this option when you’ve modified code in the body of a method or modified an existing resource.

    You can also perform this action by pressing Ctrl+Alt+F10 (or Control+Shift+Command+R on macOS).

    Apply Code Changes

    Attempts to apply only your code changes without restarting anything. Generally, you can use this option when you’ve modified code in the body of a method but you have not modified any resources. If you’ve modified both code and resources, use Apply Changes and Restart Activity instead.

    You can also perform this action by pressing Ctrl+F10 (or Control+Command+R on macOS).

    Run

    Deploys all changes and restarts the app. Use this option when the changes that you have made cannot be applied using either of the Apply Changes options. To learn more about the types of changes that require an app restart, see Limitations of Apply Changes.

    Enable Run fallback for Apply Changes

    After you’ve clicked either Apply Changes and Restart Activity or Apply Code Changes, Android Studio builds a new APK and determines whether the changes can be applied. If the changes can’t be applied and would cause Apply Changes to fail, Android Studio prompts you to Run your app again instead. However, if you don’t want to be prompted every time this occurs, you can configure Android Studio to automatically rerun your app when changes can’t be applied.

    To enable this behavior, follow these steps:

    Open the Settings or Preferences dialog:

    • On Windows or Linux, select File > Settings from the menu bar.
    • On macOS, select Android Studio > Preferences from the menu bar.

    Navigate to Build, Execution, Deployment > Deployment.

    Select the checkboxes to enable automatic Run fallback for either of the Apply Changes actions.

    Click OK.

    Platform-dependent changes

    Some features of Apply Changes depend on specific versions of the Android platform. To apply these kinds of changes, your app must be deployed to a device running that version of Android (or higher).

    Type of change Minimum platform version
    Adding a method Android 11

    Limitations of Apply Changes

    Apply Changes is designed to speed up the app deployment process. However, there are some limitations for when it can be used. If you encounter any issues while using Apply Changes, file a bug.

    Code changes that require app restart

    Some code and resource changes cannot be applied until the app is restarted, including the following:

    • Adding or removing a field
    • Removing a method
    • Changing method signatures
    • Changing modifiers of methods or classes
    • Changing class inheritance
    • Changing values in enums
    • Adding or removing a resource
    • Changing the app manifest
    • Changing native libraries (SO files)

    Libraries and plugins

    Some libraries and plugins automatically make changes to your app’s manifest files or to resources that are referenced in the manifest. These automatic updates can interfere with Apply Changes in the following ways:

    • If a library or plugin makes changes to your app’s manifest, you can’t use either Apply Code Changes or Apply Changes and Restart Activity and have to restart your app before you can see your changes.
    • If a library or plugin makes changes to your app’s resource files, you can’t use Apply Code Changes , and you must use Apply Changes and Restart Activity to see your changes.

    You can avoid these limitations by disabling all automatic updates for your debug build variants.

    For example, Crashlytics updates app resources with a unique build ID during every build, which prevents you from using Apply Code Changes and requires you to restart your app’s activity to see your changes. You can disable this behavior so that you can use Apply Code Changes alongside Crashlytics with your debug builds.

    Code that directly references content in an installed APK

    If your code directly references content from your app’s APK that’s installed on the device, that code can cause crashes or misbehave after clicking Apply Code Changes . This behavior occurs because when you click Apply Code Changes, the underlying APK on the device is replaced during installation. In these cases, you can click Apply Changes and Restart Activity or Run , instead.

    Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.

    Источник

    Читайте также:  Как поделиться паролем вайфая с андроида
    Оцените статью