See error in android studio

How to fix “Android Studio doesn’t see device” in Android Studio?

In Android Studio, sometimes the list of devices and emulators doesn’t list your physical device when you try to plug it in. Or you may have faces a situation when you plugged the phone in for the first time, no dialog appeared asking if you trust the computer. But the laptop is already allowed to connect to the mobile device. However, the button Run does not allow to deploy the app to the connected device because it thinks that there is no connected device. So you may get confused about what’s wrong with the device. Before doing anything, just check the following configuration. Configuring Your System to Detect Your Android Device

  1. Install the USB driver for your Android device.
  2. Enable USB debugging on your Android device.
  3. If necessary, install the Android development tools (JDK/SDK/NDK).
  4. Add your Android SDK to the RAD Studio SDK Manager.
  5. Connect your Android device to your development system using the USB cable provided with your device.

Even if you have done everything that is mentioned above, if you get this error “Android Studio doesn’t see device”, then you are on the right page. This article is for such programmers. In this article, there are five methods listed below to solve this issue.

How To Solve “Android Studio doesn’t see device”

Method 1

To change what your application defaults to when you click to run or debug in Android Studio, follow these steps:

Step 1: Go to the Run (on the left corner) then click on Edit Configurations.

Or you can just click here to find the “edit configurations” tab :

Step 2: Select the project. Find the Target Device section under the General tab on the Android Application page.

That seems to be where you toggle what the project builds too. If you’re importing a project it actually defaults to Emulator, not sure why. You can also select “Open Select Deployment Target Dialog” to list both connected as well as emulated devices.

Method 2

If Android Studio doesn’t even detect your device using ‘ADB devices’. then try to switch to PTP instead of MTP on your device. To do so, just click on “File transfer via USB touch for more options” in the notification area of the device.

and then choose the PTP option.

Then you will get a popup on your device regarding access. Just try restarting Android Studio to show up there as well though.

Method 3

On your device:

Go to settings/ developer settings / allow USB debug mode

If you might have the device currently connected to your PC, then ‘allow USB debug mode’ option is disabled. Just disconnect the device and the option should now be available. If you are using Android 4.2 and newer, the Developer options are hidden by default. To make it available, go to Settings > About phone and tap Build number seven times.

Читайте также:  Шутеры для слабых андроид устройств ссылки

Return to the previous screen to find Developer options.

Method 4

You may need to restart ADB, from the terminal. To do so just type the below commands:

  • adb kill-server
  • adb start-server

or from ddms(If you are using Android Studio version My Personal Notes arrow_drop_up

Источник

Методы лечения различных ошибок в Android Studio при разработке проекта

Сегодня хотел бы поделиться своим анализом и способами лечением разных ошибок при разработке своего продукта в Android Studio. Лично я, не раз сталкивался с различными проблемами и ошибками при компиляции и/или тестировании мобильного приложения. Данный процесс, всегда однообразный и в 99% случаев и всегда нужно тратить n-колличество времени на его устранение. Даже, когда ты уже сталкивался с данной проблемой, ты все равно идешь в поисковик и вспоминаешь, как же решить ту или иную ситуацию.

Я для себя завел файлик, в котором отметил самые частые ошибки — потратив на это несколько часов и перечислил самые популярные ошибки (в дальнейшем планирую просто их запомнить), чтоб сократить свое время в дальнейшем.

Итак, начну по порядку с самой распространенной проблемы и дальше буду перечислять их по мере появления:

1) Если подчеркивает красным код, где используются ресурсы: R. — попробовать (но вероятно не поможет): Build -> Clean Project.

В принципе на Build -> Clean Project можно не терять времени, а лучше всего — слева переключиться на Project, открыть каталог .idea, затем каталог libraries и из него удалить все содержимое. Затем нажать кнопку Sync Project. А затем (если все еще красное, но скорее всего уже будет все ок ) Build -> Clean Project.

2) После внезапного выключения компьютера, после перезапуска может быть во всех проектах весь код красным. Перед этим может быть ошибка: Unable to create Debug Bridge: Unable to start adb server: Unable to obtain result of ‘adb version’. Есть три решения — первое помогло, второе нет (но может быть для другого случая), а третье — не пробовал:

а) File — Invalidate Caches/Restart — Invalidate and Restart

б) Закрыть студию. В корне папки проекта удалить файл(ы) .iml и папку .idea. Вновь запустить студию и импортировать проект.

в) Нажать Ctrl-Alt-O и запустить оптимизацию импорта.

Кстати, adb сервер можно проверить на версию (и работоспособность) и затем перезапустить:

3) Если Android Studio выдает приблизительно такую ошибку: Error:Execution failed for task ‘:app:dexDebug’.

Надо слева переключиться на опцию Project, найти и удалить папку build которая лежит в папке app, т.е. по пути app/build. Затем перестроить весь проект заново: Build -> Rebuild Project.

Такое же решение если ошибка типа: «не могу удалить (создать) папку или файл» и указан путь, который в ведет в app/build. Тоже удаляем папку build и ребилдим проект.

4) В сообщении об ошибке упоминается heap — виртуальная память. А ошибка обычно вызвана ее нехваткой, т.е. невозможностью получить запрашиваемый объем. Поэтому этот запрашиваемый объем надо уменьшить, т.е. переписать дефолтное значение (обычно 2048 MB которое можно изменить в настройках), на меньшее 1024 MB.

В файле проекта gradle.properties пишем:

5) Android Studio пришет примерно такую ошибку: Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to «83648b99316049d63656d7276cb19cc7e95d70a5»

Возможные причины (кроме необходимости регулярного обновления SDK):

а) Загруженный проект был скомпилирован с помощью уже несовместимого старого gradle плагина. В этом случае надо найти и подключить в своем build.gradle проекта этот более старый плагин. т.е. попробовать более старые версии, например: 1.1.3 (часто именно 1.1.x и подходит).

Найти все версии можно здесь.

б) Если в build.gradle проекта используется beta-версия плагина — это означает, что срок ее истек. Посмотреть последние релизы (продакшн и бета) можно также здесь:

6) Иногда при подключении сторонних библиотек могут дублироваться некоторые файлы (обычно связанные с лицензированием). В сообщении будет что-то содержащее слова: duplicate files. Решение — надо посмотреть в сообщении об ошибке или в документации подключенной сторонней библиотеки — какие именно файлы стали избыточными, и перечислить их в build.gradle модуля для исключения (exclude) из билда.

Читайте также:  Raft survival android mod

Это делается в директиве packagingOptions (которая, в свою очередь, находится в директиве android).

Источник

Fix “Module not specified” Error in Android Studio

Whenever we try to debug the application on Android Studio we may encounter the error “Module not specified” in the Android Studio. So, In this article, we will discuss 4 different methods for fixing the “Module not specified” error in Android Studio.

Method 1

All you need to do is Resync your project Gradle files to add the app module through Gradle. Following are the steps:

  • In the root folder of your project, open the settings.gradle file for editing.
  • Delete the line include ‘:app’ from your file.
  • On Android Studio, click on the File Menu, and select Sync Project with Gradle files.
  • After step 3, Add again, include ‘:app’ to the settings.gradle file.
  • Re-run Sync Project with Gradle files again.

After this, your error “Module not specified” will be resolved.

Method 2

Another best method to resolve this error is to try to delete the app.iml in your project directory and restart android studio. This will definitely work out and your error of “Module not specified” will be resolved.

Method 3

If the above two methods did not work for you, you can follow the below steps to resolve your issue.

  • Firstly, close all the android studio projects.
  • then, remove the project from the recent projects in android studio wizard.
  • Restart Android Studio.
  • Instead of open an existing project Android Studio project, use the import option (Import project- Gradle, Eclipse ADT, etc).
  • File ->Sync project with gradle files.

Method 4

And at last, if all of the above methods did not work for you, you can also clean your project and do invalidate caches/restart from the menu bar. After that, your project might be fixed and the error will be resolved.

Источник

How to Fix “SDK location not found” in Android Studio?

Google developed Android SDK which is a Software Development Kit developed by Google for the Android platform. You can create Android apps using Android SDK, and you don’t need to be an expert to use it. Android SDK and Android Studio come bundled together, with Google’s official integrated development environment (IDE) for the Android operating system.

In this article, we see how to fix an error that is related to the main Android building component of Android Studio that is the Android SDK. The most common error related to Android SDK is “SDK location not found“. This message pops up stating that the location of Android SDK was not detected when the path of SDK is assigned incorrectly. There can also be other reasons for this error message as well and we will see ways to get rid of this error.

When switching from one IDE to another (Like from Eclipse to Android Studio)

Method 1

In this case, follow the below steps:

Method 2

In case the above procedure doesn’t work then add the ANDROID_HOME variable in “Environment Variables” as C:\Users\Username\AppData\Local\Android\Sdk.

Method 3

In case it does not work even then, then you need to change the directory path on Project Structure as well.

  • Close the current project and you’ll see a pop-up with a dialog which will then proceed to Configure option.
  • Configure -> Project Defaults -> Project Structure -> SDKs on left column -> Android SDK Home Path -> give the exact path as you did on local.properties and select Valid Target.

Method 4

A settings.gradle file might be missing from the project. Make sure that the file exists from the project you are importing. If not add the settings.gradle file with the following:

Читайте также:  Which one better ios or android app

Save the file and put it in the top-level folder in your project.

Источник

Fix “Android emulator gets killed” Error in Android Studio

Sometimes, (maybe after updating Android Studio) you might encounter a strange error, which might cause you a nightmare, the error is thrown by the Studio itself and it says:

Uggh…Now, what’s this error all about? Why did it happen on the system? How do I fix it? Follow the Steps Below, and you’ll certainly solve it yourself!

You might encounter this error when you start the Android Emulator and then wait for it to get started but only see the process running and the GUI never comes into play, this is especially very nasty and troublesome when you have some important work to do (maybe a client project to test in the 11th hour) and then suddenly your hope of running the emulator gets numb because the process which was still running went out nowhere and got killed.

Method 1: Update Android Emulator to the Latest Release

As blunt as it may sound, but updating the emulator which you’re running could simply end your problem, for eg. if you’re working on API Level 30 and your emulator version is 30.1.2 then updating it to 30.1.5 would perhaps resolve your issue. Updating Emulator is a breeze, simply: Android Studio -> Go to preferences -> Android SDK -> Then find and update the Android Emulator from the list. Use the Image below if you get stuck at any place:

Updating Android Emulator

Method 2: Clear your Disk Space

Sometimes, the only force acting between you and the emulator running is the low disk space, clearing the disk space and re-running the emulator (after restarting the studio) could resolve this issue for you, it’s simply an easy lookout for the node modules .

ProTip: Clearing you Android Studio cache could clear huge chunks of data!

Method 3: Enabling Support for OpenGL

If your emulator is a device with the Google Play Services enabled, the error might be related to “OpenGL” to fix this, simply:

  1. Go to: Tools >Android >AVDManager
  2. Press the “edit” (pencil) icon next to your AVD
  3. Change “Graphics” to “Software”.

Method 4: Install the Intel x86 Emulator Accelerator on your system

Apart from updating the Android Studio Emulator on your system, you should also consider installing the Intel x86 Emulator Accelerator as Android is a large Operating System and some system images run on the old x86 bit architecture. To Install the x86 Emulator Accelerator

  1. Go to Preferences
  2. Navigate to Android SDK
  3. Mark the Checkbox against “Intel x86 Emulator Accelerator (HAXM)”

You may refer to the below screenshot if you need help:

Installing the Intel x86 Emulator (HAXM)

Method 5: Parallel SDK Installation (Rare)

If all the above-mentioned steps didn’t work out for you and you’re still not able to run the Emulator, it might be the fact that there are two SDK Installations in your system and the “ANDROID_HOME”points to the wrong location.This error might occur if you recently installed Nativescript or software like that. In order to fix it, follow:

  1. Android Studio settings
  2. Find the proper Android SDK location
  3. Update the environment variable and restart Android Studio.

Fixing Parallel SDK Installation

Conclusion

All the above-mentioned methods would’ve solved your issue, and your emulator would be up and running again, however, if the odds turn on to be against you, always remember that a clean installation of the whole setup would fix this problem.

Источник

Оцените статью