- Методы лечения различных ошибок в Android Studio при разработке проекта
- Gradle error on Android Studio startup
- Failed to build project with Android studio
- 6 Answers 6
- Not the answer you’re looking for? Browse other questions tagged gradle android-studio or ask your own question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- Gradle build error in Android Studio 3.0
- 3 Answers 3
- SOLUTION 01 (Didn’t work for me):
- SOLUTION 02 (Worked for me):
- Android Studio error installing Gradle
- 14 Answers 14
Методы лечения различных ошибок в 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) из билда.
Это делается в директиве packagingOptions (которая, в свою очередь, находится в директиве android).
Источник
Gradle error on Android Studio startup
Every time I start Android Studio I get the following error:
Gradle ‘VertretungsplanProject’ project refresh failed: Could not fetch model of type ‘IdeaProject’ using Gradle distribution ‘http://services.gradle.org/distributions/gradle-1.6-bin.zip’. A problem occurred configuring project ‘:Vertretungsplan’. A problem occurred configuring project ‘:Vertretungsplan’. Failed to notify project evaluation listener. A problem occurred configuring project ‘:libraries:actionbarsherlock’. Failed to notify project evaluation listener. Could not normalize path for file ‘P:\Projekte\VertretungsplanProject\libraries\actionbarsherlock:Vertretungsplan\libs\android-support-v4.jar’. The syntax for the filename, directoryname or the volume label is wrong
My project looks like this:
build.gradle of :Vertretungsplan:
build.gradle of :VertretungsplanProject is empty.
build.gradle of :actionbarsherlock:
When I want to compile now this error appears:
Deprecated make implementation
Old implementation of «Make» feature is enabled for this project. It has been deprecated and will be removed soon. Please enable newer ‘external build’ feature in Settings | Compiler.
After changing this setting to Use external build everything is working fine. But this appears every time I start Android Studio and this is really annoying.
Источник
Failed to build project with Android studio
Can anyone tell me why I’m getting this error with AndroidStudio?
I have installed Android Build-tools 19.0.1 from the Android SDK manager
6 Answers 6
Check all your build.gradle files whether they are using the 19.0.x version or not.
buildToolsVersion will be defined under the android tag inside the build.gradle file, like this:
You can find a list of versions for the Android Build Tools here as well as in the SDK Manager.
Go to Window->Android SDK Manager and run it
You will see Android Build-Tools version installed.
Change build.gradle to reflect the installed version of build tools
This worked for me
Install the version which is shown in error
This seemed to work for me. I had to update the Default settings then restart the IDE:
- File->Other Settings->Default Project Structure
- Under Project Settings: Project, set Project SDK as Android SDK.
- Click Edit button
- For Android SDK, set Build target to Android 4.4.2
- Click Ok.
- Restart IDE
- Then rebuild. Seemed to work after that..
This is assuming you’ve already installed Android-19 and still having difficulties.
If you have installed the required version of the build tools and it does not work:
Eclipse and the Android Studio likely use two different copies of the SDK, and you have updated the other copy.
Edit your project level build.gradle file and set gradle version to the latest version now it is 3.2.1
It’s helpful to remember that you will have build.gradle files for each module in your Android Studio Project.
I kept hitting my head against the wall — «Where the heck is that line everyone’s telling me to change?!» — until I looked in the
/dev/AndroidProjects/xxprojectnamexx/app folder and looked at the build.gradle file there.
Not the answer you’re looking for? Browse other questions tagged gradle android-studio or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.12.3.40888
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Источник
Gradle build error in Android Studio 3.0
Can you please help me to resolve the Gradle build issue in Android 3.0 ?
I am new with Android Studio. Here are my configurations in the AS 3.0:
build.gradle dependencies (Android Plugin for Gradle):
Settings»>
Stacktrace from Android Studio:
3 Answers 3
It’s a problem related to Android Studio 3.0 and the corporate networks. I had the same problem.
I leave you 2 solutions:
1rst: You must add certificates manually to your java security certs (used by Android):
C:\Program Files\Android\Android Studio\jre\jre\lib\security\cacerts
SOLUTION 01 (Didn’t work for me):
Download the Certificate you need (just copy the URL with the problem and paste it into ):
And run the command:
If you never changed the password of cacerts the default one is changeit :
SOLUTION 02 (Worked for me):
Download the pom entering to the URL site and store it in your local repo:
I phase the same issue i formate the android studio and install 3.0 but issue not resolved so for resolving the issue i done following things 1.go to view and seed which files are changed. 2.the files may change after updating the plugins and platform.te 3.so you need to revert all files changes which happen due to plugin updates.
4.Now you have to notice which files changed and go to each file local history and revert the changes for that suppose gradle file is changes so you need to right click that file and go to local history and than select show history
you will see two files one which will be for recent changes and one which will show you all the recenct changed files so you need to properly select the file which you have changed according time ,date
in above figure you can see on the left top corner their is a revert option if you click on that all chages will be reverted so click on that revert option and save the changes
do this with all files which is changed due to gradle plugin update and sync the project you will solve the issue .
Источник
Android Studio error installing Gradle
When I try to build a project on Android Studio, I get this error:
What can I do to fix it?
UPDATE:
When I look at the Error Log, I saw this:
14 Answers 14
Please read the log from:
- On Microsoft Windows: [Windwos Drive]\Documents and Settings\[your username]\.AndroidStudioPreview\system\log
- On Mac and Linux:
And you will find the tmp download path of gradle-1.6-bin.zip . For example, mine is:
So I know the cause: I downloaded an incomplete ZIP package.
Then I downloaded the full ZIP package from http://services.gradle.org/distributions/gradle-1.6-bin.zip manually and copied this ZIP package to:
- Windows: C:\Documents and Settings\Kiki.J.Hu\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\
- Mac OS X:
Everything is OK now.
/Library/Logs/AndroidStudioPreview for me. The stuck and locked zip was located at
For OS X:
Install Homebrew as a package manager. Then on Terminal, run:
It is the easiest way to get Gradle.
Before you click to new project, go to configure and set your proxy. I recommend set host name and port number, since I had problems with auto-detect proxy settings. Check your connection in settings.
I also had issues downloading Gradle through Android Studio.
This was my workaround:
- Download Gradle directly from http://services.gradle.org/distributions/gradle-1.6-bin.zip
- Copy the contents of gradle-1.6 to \Android\android-studio\plugins\gradle
- Copy gradle.jar to \Android\android-studio\lib\
- Restart Android Studio
Hope this helps!
Edit the gradle wrapper settings in gradle/wrapper/gradle-wrapper.properties and change gradle-1.6-bin.zip to gradle-1.8-bin.zip.
./gradle/wrapper/gradle-wrapper.properties :
It should compile without any error now.
In my case this was because the system had low memory. When I closed some applications, the error disappeared.
For me it turned out to be my firewall, which is VIPRE, was blocking the Gradle.org site and quietly causing a bad gradle-1.7-bin.zip to be created under .gradle\wrapper\dists\ .
I had to open VIPRE and add gradle.org to «Bad Web Site Exceptions» (menu File -> Settings -> Firewall).
Then I downloaded http://services.gradle.org/distributions/gradle-1.7-bin.zip using a browser and overwrote the bad version. I restarted Android Studio, and all is good.
FYI, on my Mac, it was downloading Gradle into the
/.gradle directory. You can see how it’s progressing by looking there:
I noticed that my MyProject/gradle/wrapper/gradle-wrapper.properties file was completely empty, so I deleted it and Android Studio proceeded to download whatever it needed.
After that it worked.
I tried Kiki Hu’s solution, and it worked. After that, there will be more downloads from the Maven repository which includes Dalvik Debug Monitor Server (DDMS), Guava, etc., which again is not required if you are exporting from Eclipse into Android Studio.
If you’re like me, you tried to start a version prior to 0.2.0. Following Google’s notes in Getting Started with Android Studio, you’ll need to remove and re-install Android Studio.
«Note: There is not a patch update available from 0.1.9 to 0.2. To update from Android Studio 0.1.x to 0.2.x, you must install a new Android Studio bundle from this page. The reason for that is that we have made changes to the bundled SDK such that it includes a pre-configured local Maven repository which can serve up the v4 support library and which is required for creating new projects.«
Also be aware that if you have your Android SDK files stored in C:\Program Files (x86)\Android\android-studio\sdk you should move them before the uninstall, or you’ll need to download the SDK files again.
After the un-install and re-install, it is now working on my Windows 7 64-bit system.
Источник