I have this problem. I downloaded this API from https://github.com/tlaukkan/zigbee4java
I tried several times to import the project on Android Studio 2.3.1 but always Gradle fail to sync with this Error:Configuration with name 'default' not found.
I read on other posts about this error but I do not understand what to change because this API should be correct.
Thank You for support.
Best Regards.
EDIT
these are the steps I did:
- unzip file
- open Android Studio
- select Import Project (Eclipse ADT, Gradle, etc.)
- I select zigbee4java-master
- and then Start Gradle Build
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
build.gradle
import org.codehaus.groovy.tools.StringHelper
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
def zigbee4javaProfilesArray=StringHelper.tokenizeUnquoted(zigbee4javaProfiles)
group = 'org.bubblecloud.zigbee4java'
apply plugin: 'java'
apply from: 'build-common.gradle'
/* Include build scripts from all profiles selected in 'gradle.properties' */
allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url "http://repository-bubblecloud.forge.cloudbees.com/release/"
maven { url "http://repo.maven.apache.org/maven2" }
}
}
dependencies {
for (zigbee4javaProfile in zigbee4javaProfilesArray) {
switch (zigbee4javaProfile) {
case 'android':
println 'zigbee4java: Including Android build'
compile project(':zigbee-serial-android')
compile project(':zigbee-console-android')
break;
case 'javase':
println 'zigbee4java: Including JavaSE build'
compile project(':zigbee-serial-javase')
compile project(':zigbee-console-javase')
break;
}
}
}
I hope these informations are correct to understand my problem.
Thank You
EDIT
About GRADLE 3.0 problem I tried this:
on Settings I set "Use a local Gradle Distribution" and I set the path to a downloaded Gradle 2.2.1 distribution. But this not solved the problem.
I also tried this uninstalled Android Studio 2.3.1 and Install Android Studio 1.1 with Gradle 2.2.1 by default but again the same problem.
The problem could be: import org.codehaus.groovy.tools.StringHelper ???
Finally I solved the problem.
I don't say that all my steps are necessary but this is what I did,
Simply I uninstall all Android Studio and all the Android folders under ..\Users\userName\ and under \Users\userName\AppData\Local\Android.
This to be sure to have a clean installation.
After I install Android Studio 2.3.1 patch to 2.3.3 than downloaded necessary Android API (API 21 in my case).
Then in File-> Settings-> Gradle I checked "Use local Gradle distribution" where mi distribution is gradle-2.2.1
At the end I select Import Gradle Project from the Android Studio Start Menu and no Gradle error message appear and everything seem to be imported correctly.
My opinion is that, the first time I tried to import the project using Gradle 3.2. I suppose some files and folder was generated not correctly, so when I tried to use the correct Gradle version the import not work properly.
When I delete everything and used the correct Gradle version the import was successful.
Thanks to all the people that answer to my question, and tried to help me.
Best Regards
Related
I am new to Android and WearOS and also to Gradle, and I just want to follow along this Codelab:
https://codelabs.developers.google.com/codelabs/watchface/index.html#0
So I downloaded Android Studio and imported the project
https://github.com/googlecodelabs/watchface
but when compiling I just get the error
Failed to resolve: com.google.android.support:wearable:2.0.0
I already tried to change SDK Versions and other things, but it didn't help.
I'm pretty sure it's just a few version settings, but I have no idea where to look.
Did anyone maybe complete this codelab and made it run with the "actual" version of AndroidStudio?
thanks,
Thorsten
The code on github was last updated in May 2017, which is a shame, as it is a useful introduction to watchfaces. A number of things have changed since then. There is even a pull request on github with gradle updates from Nov 2018, but it hasn't been merged.
Your 'Failed to resolve' error is likely related to Google now providing some packages in their own Maven repository, in addition to jcenter.
This can be fixed by adding google() to the repositories closures in the Package build.gradle file:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
The version of the gradle plugin has been changed to 4.0.2 above too, so also update the file gradle-wrapper.properties with:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Gradle should now build, but it may still log some warnings or errors in the Build window which you can open at the bottom of Android Studio.
The gradle dependency keyword 'provided' has been replaced with 'compileOnly' and 'compile' with 'implementation'. Shift+Ctrl+R in Android Studio will enable you to easily do the replacement project-wide.
It should also be useful for updating compileSdkVersion and targetSdkVersion (to 30) and buildToolsVersion (to 30.0.2) in all the module build.gradle files.
The package versions are out of date, with the wearable ones currently at 2.8.1 and play-services-wearable at 17.0.0. Ctrl+Alt+Shift+S takes you to 'Suggestions' in 'Project Structure', which can help you in future to stay current.
The last problem is that the Android Support Library has been obsoleted in favor of jetpack/androidx. See the old reference.
In this project, it is only a problem in the build.gradle of module 5-palette. You may replace 'com.android.support:palette-v7:23.3.0' with 'androidx.palette:palette:1.0.0'. See Jetpack Artifact Mappings. You then need to change the import statement in MyWatchFaceService.java.
Finally add the following line to gradle.properties:
android.useAndroidX=true
I was following a tutorial to develop icon pack for android and when I imported the project I got several errors and it was solved here - Gradle Version 4.6 - Absolute path are not supported when setting an output file name
After solving that error, the following error poped up.
Could not find com.android.tools.build:aapt2:3.2.0-4818971.
Searched in the following locations:
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
Required by:
project :licensing
I tried to open the URLs and I was able to download JAR (aapt2-3.2.0-4818971-windows.jar) and JSON (aapt2-3.2.0-4818971.pom.json) files from the first 2 URLs. Should I copy these files somewhere? What should I do to solve this error?
Most likely you do not have the Google repository in your project's build.gradle file. Add google() in BOTH locations as shown below:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I was able to solve the issue by adding google() in both locations:
File -> Project Structure -> Project -> *Now add ", google()" in
Android Plugin Repository
and
Default Library Repository
*
When you upgrade to 4.6 version of gradle. You need following upgrades too. Gradle Plugin Release page.
1. Android Studio 3.+
You need Android Studio version 3.+ to have 4.6 version of gradle. At the time of post latest release was 3.2.1. You can see latest release on this page.
2. Gradle Plugin 3.1.+
You need 3.1.+ gradle plugin for gradle-4.6 support. Check in project level build.gradle.
classpath 'com.android.tools.build:gradle:3.2.1'
At the time of post latest version was 3.2.1. You can see latest release here.
3. Add Google Maven Library
You need to add Google Maven library to project level build.gradle like below code.
buildscript {
repositories {
google()
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
...
}
}
allprojects {
repositories {
google()
...
}
}
see the dependencies of module :licensing and use com.android.tools.build:aapt2:3.2.0 (or even "com.android.tools.build:aapt2:3.2.0:windows") there, which is the final version ...that 4818971 version should ordinary come with an alpha prefix/suffix (the version number seems to be incorrect). maybe adding repository google() might be required, too. ordinary, that dependency should be present; removing that dependency might be another possible option.
For those people who still face exactly the same problem even after adding two google to BOTH positions in relevant gradle file.I would suggest you to check Android Studio -> Preferences -> HTTP Proxy page.
If you find it says some warnings like "...have set JVM proxy to 127.0.0.1".Then you should consider vpn-related issues which depends on your context.
If your desktop is MacOS, then go to Network setting page, advance->proxy tab,uncheck all the checkbox there.
Back to your IDE as following steps: Android Studio->File->Invalidate Caches/Restart.After that,go back to check Android Studio -> Preferences -> HTTP Proxy page again,previous warnings should be gone.Run again.
I solved my issue by upgrading my classpath from
'com.google.gms:google-services:4.0.0
to
'com.google.gms:google-services:4.2.0'
hope this helps
I just updated to Android Studio 3.0 and I'm getting this error with an existing project:
Kotlin not configured
When I go to Tools>Kotlin>Configure Kotlin in Project, I get an error saying "no configurators available". Also get the error below with the red java:
I've also tried:
Restarting
Clean and Rebuild
Invalidate caches/restart.
I first tried with invalidate cache/ restart option but it doesn't help me.
When I updated Kotlin to 1.1.60 in project's gradle file, problem is solved.
Also, use this in app's gradle for stdlib
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.1.60"
instead of
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.60"
In Android Studio, click on File -> Invalidate Caches / Restart... , then select "Invalidated and Restart". This solved my problem.
This error also occurs if you have the mavenCentral() repository missing in allprojects.
Your build.gradle (:app) should contain at least this:
allprojects {
repositories {
google()
mavenCentral()
}
}
jcenter() would work as well (for now), but that repository reached end-of-life and shouldn't be used any more.
Closing and restarting Android Studio works for me in that case. Important is that there are no other projects opened in Android Studio before you close it. I suspect that closing Android Studio with multiple opened project windows sometimes messes up the configuration especially after plugin upgrades etc.
Important Update
You should check JDK version before setting config
Kotlin gradle config page has detailed information about this.
Step 1
Check kotlin version in project level gradle file.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
For kotlin_version '1.2.x' Use jdk NOT jre
Step 2
Check JDK version in File > Project Structure
Or check in build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
If no JDK version is set in Project Structure, then choose by Android Studio version
JDK version is 1.7 for Android Studio Version < 2.2.1
JDK version is 1.8 for Android Studio Version < 2.2.1
Because Android Studio is bundled with jdk 1.8 since 2.2.1 version.
You have 3 options of kotlin stdlib, choose according JDK version
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" //jdk_version == 1.8
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" //jdk_version == 1.7
implementation"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // jdk_version is < 1.7
if kotlin version is'1.1.x' Use jre NOT jdk
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" // or jre8
Update Kotlin Version?
You can update Kotlin version from Tools > Kotlin > Configure Kotlin Updates
Kotlin-stdlib-jre7 is deprecated since 1.2.0 and should be replaced with kotlin-stdlib-jdk7
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
I have faced this issue recently... when I updated to Android Studio 3.1 .
I did a few things to fix this.
First I updated the Kotlin version in my app gradle file and added
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.31"
in my app gradle file. But this alone didn't fix it.
Then uninstalled the kotlin plugin from settings, restarted Android Studio and installed it again.
EDIT :
This is my project gradle file
buildscript {
ext.kotlin_version = '1.2.31'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.31"
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}
And this is my app gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
...
}
buildTypes {
...
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
kapt { generateStubs = true }
}
repositories {
...
}
dependencies {
...
...
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.31"
...
...
}
apply plugin: 'com.google.gms.google-services'
just delete .idea folder from project,and run android studio again, it will resolve KOTLIN NOT CONFIGURED issue.
A common reason of the "Kotlin Not Configured" message is an internal Android Studio exception due to a bad plugin.
In order to fix that you should disable the bad plugin.
When such plugin crash occurs, on the "Wellcome screen" you'll see a small notification (see illustration image) where you can click it and disable the bad plugin:
None of the other solutions solved my problem. I ended up figuring out that the problem lied in the google services version. Just update it to the latest.
Top level gradle at dependencies:
classpath 'com.google.gms:google-services:4.1.0'
In my case, after the update of Android Studio and plugins, I could create new projects, but my old projects were having "Gradle Sync Issues".
The solution was in File/Project Structure.../App/Dependencies:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
And then I just updated the Kotlin version in my project build.gradle:
From:
ext.kotlin_version = '1.2.30'
To:
ext.kotlin_version = '1.3.21'
Then I tried Sync again.
Obs: You can check your Kotlin version in Tools/Kotlin/Configure Kotlin Plugin Updates
I have tried all above solutions but non of them works for me.
Then finally I got success with below solution, so it may helpful for some one like me.
Delele all .iml files (in root project, libraries and modules)
Rebuild project
In my case I had to update Android studio from version 3.4.1. to 3.5 and it resolved the kotlin not configured error.
Delete .AndroidStudio3.6 folder in C:\Users\Username and re-open Android studio works for me
The only fix for me was adding
apply plugin: 'kotlin-android-extensions'
in build.gradle (:app)
One other point to check is version of your Gradle in gradle-wrapper.properties, if you use one.
Make sure that
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Has version 4.1 or higher.
You may also have the following in your build.gradle:
task wrapper(type: Wrapper) {
gradleVersion = '4.1'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
Where Gradle version is lower that 4.1
Though I see that the question already has answers that work, one might also try the following solution.
Right click on the file name (Main.kt) -> Run 'Main.kt'.
This will download a gradle file from the gradle.org website.
Wait for it to unzip. The errors were cleared.
In my case, it was a broken update of one of the plugins I've used. Check your error logs from Android Studio this will lead you to what is the problem.
Simply Create a new Activity and select its language to kotlin Android studio Automatically configured kotlin for you.
I have an Android studio project that wrote in Android Studio version 1.3.2. Now in another PC with Android Studio 2.1.2 I want to import or open that project to it. But when I try, and while opening, error occurred with my Gradle version and want from me to download necessary Gradle version.
But for my reasons, I don't want to download new data with Android studio. how can I manually transfer old PC Gradle to new one? or is there simpler way to resolve that?
Method: 1
Try "File -> New -> Import Project"
or Create new project and copy-paste all project files(Java,XML,Resource) except gradle folder.
Method :2
Or After Import file just change 2.1.2 to 1.3.2
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
Adding local Gradle to projects would be really helpful
1.Download Gradle http://www.gradle.org/downloads
2.Install
3.Set Gradle home to the install directory like below :
there is sample project check it : https://github.com/foragerr/SO-35302414-local-gradle-plugin
Open your app level build.gradle file and change the gradle version accordingly like
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
so just change your version from 1.3.2 to 2.1.2
1.I faced same problem before .Ok you need to copy .java file and .xml layouts strings,colors,dimen,drawble images and others in old project
2.And create new android project in your new android studio and paste that file into that project that's it
NOTE: Copy only required files only
Try "File -> New -> Import Project" or just create new project and just copy-paste all project files except gradle folder (change gradle version in build.gradle after copy)
You Need To Check This From Google Android.
Plugin version Required Gradle version
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3+ 2.14.1+
So You Cannot Use Old Gradle Build With new Android Studio Version According to Google.
You Can Use the Older Version of Of Android Studio to Make Your Project Work With the Old Gradle System
Look in the SDK Manager what is your highest Android SDK Build-tools version, and copy this version number in your project build.gradle file, in the android/buildToolsVersion property The Build Tool Version Propert Should Be Compatible With the Gradle.
2 ways you could choose to give a try, either of them is okay for me:
1.Copy files and make some configurations:
create a new empty Android project, copy only java source files and layout\drawable\colors\dimens etc but Not exclude AndroidManifest.xml files copy into your new project
override the AndroidManifest.xml's application tag with the content of the old project's(only )
build the new project, you will meet some 'Not Found' errors, modify package names and path of some files until errors disappear
done!
2.edit some of gradle files:
modify contents of "/Users/your_name/your_project_directory/gradle/wrapper/gradle-wrapper.properties(path could be different on windows)" , notice distributionUrl="something like https://mirrors.somewhere.net/mirror/gradle/gradle-xx.xx-all.zip", xx.xx determines the version of gradle the project used
modify contents of "/Users/your_name/your_project_directory/build.gradle" and any modules included in your project will have their own build.gradle file, notice the following:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:xx.xx.xx'
}
}
Then change 'com.android.tools.build:gradle:xx.xx.xx' which determines the Plugin version to the version corresponding to the version of 'gradle-xx.xx-all.zip' which determines the Gradle version as #AndroidHacker's post:
Plugin version Required Gradle version
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3+ 2.14.1+
done!
first thanks for your answers. but I finally find the solution to solve this issue without download anything and just with a few changes in versions and files.
1- Open project folder then /gradle/wrapper/gradle-wraper file.
2- In this txt file, change distributionUrl value to: https\://services.gradle.org/distributions/gradle-2.10-all.zip
3- Back to Android Studio.In your project's build.gradle file, change classpath to com.android.tools.build:gradle:2.1.2
4- In your app's build.gradle file, change buildToolsVersion to "23.0.3"
I was syncing fine and then suddenly when I tried to run a test on a device from Android Studio I started getting the error:
Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable ...
I've looked around and I found from the gradle website that the latest version is 2.10, I tried adding that to my dependencies with no luck. I've tried various version numbers with various errors like the following:
Could not find com.android.tools.build:gradle:2.1
Searched in the following locations ...
I understand from all the searching I've done that its clearly a wrong version of gradle - but what IS the current version label I should be using, and how do I know it is installed on my machine ? I've always kept Android Studio updated.
So I currently have in the build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
}
UPDATED (28/03/2017):
2.4.0-alpha3 is the latest release
classpath 'com.android.tools.build:gradle:2.4.0-alpha3'
Check https://bintray.com/android/android-tools/com.android.tools.build.gradle/view for the latest gradle versions.
2.0.0-alpha1 is on the Canary channel and apparently these releases come with an expiry date. 2.0.0-alpha3 is the latest release. Switch to
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
and you should be fine. Keep checking http://tools.android.com/tech-docs/new-build-system to know the latest releases.
You might run into some Dex error. I had to do Build > Clean Project once to get it to work.
Change your existing configuration with this
In your project view, select Gradle Scripts
Open gradle-wrapper.properties
Change this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Go to build.gradle (Project: your_app_name)
Change this line
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
to this
classpath 'com.android.tools.build:gradle:1.5.0'
Don't click Sync Now
From menu choose File -> Invalidate Caches/Restart...
Choose first option: Invalidate and Restart
Android Studio would restart. After this, it should work normally
Hope it help
Now com.android.tools.build:gradle:2.0.0-alpha3 is old
use this
com.android.tools.build:gradle:2.0.0-beta2
If your having trouble getting the plugin to resolve. Check that your including jcenter() (Jcenter) in your repositories for the buildscript. Google does not publish the plugin to mavenCentral() (Maven Central).
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}
}
As others have mentioned the latest ATM is 2.0.0-alpha3 but that could change at any time. Here is the source of truth on the latest available version:
https://jcenter.bintray.com/com/android/tools/build/gradle
As for the actual error here is the best answer is in is link. TLDR, undocumented feature of the non release plugins is they expire and you have to update.
https://stackoverflow.com/a/31293869/873237
Just solved by doing the following steps:
1 - Open gradle-wrapper.properties
Replace
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
2 - Open build.gradle (Project: app_name)
Replace
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
with
classpath 'com.android.tools.build:gradle:2.2.1'