I migrated from eclipse to android studio. I've create a new project and I want to run it on genymotion. When I press run icon, it begins to compile and give me this error :
Error:Gradle: A problem occurred configuring root project 'Khabar'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.1.0.
Required by:
:Khabardar:unspecified
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.1.0/gradle-1.1.0.pom'.
> d29vzk4ow07wi7.cloudfront.net
This is some parts of my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "example.ir.khabar"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
build.gradle in root :
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "example.ir.khabar"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile files('libs/universal-image-loader-1.8.4-with-sources.jar')
}
Could you help me? my gradle version is gradle-2.2.1-all
For me, the solution was to add the http url for jcenter, instead of https:
buildscript {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
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
}
}
In addition to Al's answer, I also had to put the url inside allprojects:
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
}
I was having the same issue on Ubuntu Mate 18.04. I was able to fix it by replacing ibm-java80-jdk & ibm-java80-jre with openjdk. Also, I did update my DNS to cloudflare DNS. But I don't think it had anything to do with the fix.
add google() in your gradle inside the repositories section will solve your problem..
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Related
This question already has answers here:
Error:(6, 0) Gradle DSL method not found: 'google()'
(11 answers)
Closed 5 years ago.
I'm trying to add an external library to my existing project. I created a libs folder and added my MaterialDrawer library in the root directory. Here is my settings.gradle file:
include ':app'
include 'libs:MaterialDrawer'
But gradle sync is failed and getting following error:
Error:Gradle DSL method not found: 'google()'
I couldn't find any solution in SO regarding my problem. Anyone would be kind enough to help?
Here is the build.gradle (Project):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}
Here is the build.gradle (app):
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.myapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 38
versionName "2.1.8"
generatedDensities = []
}
dexOptions {
javaMaxHeapSize "4g"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io"}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(":libs:MaterialDrawer")
}
apply plugin: 'com.google.gms.google-services'
Method google() was added in Gradle 4.0
You should use maven { url 'https://maven.google.com' } on old versions
Also remove repositories section from your app build.gradle (you may merge it with root build.gradle)
Read how to add library to build.gradle here
compile('com.mikepenz:materialdrawer:5.9.5#aar') {
transitive = true
}
I know there are similar questions like this but i'm new in android development and i need to learn how to import an example defining repositories and dependencies in the build.gradle project file.
After several tries i can't figure out which is the right way...
The example is this one https://github.com/neokree/MaterialNavigationDrawer
When i load the project in android studio i get an error "Configuration with name 'default' not found.", and it's ok.. i know that i have to modify the build.grandle file
repositories {
mavenCentral()
}
dependencies {
compile 'it.neokree:MaterialNavigationDrawer:1.3.3'
}
But where i have to add/replace these rows? In the buildscript area? in the allprojects? i get "Gradle DSL method not found: 'compile()'" error or fix plugin version alert if i try to change something.
original build.grandle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
Your problem is in setting.gradle file in the MaterialNavigationDrawer project. As you can see
include ':app', ':MaterialNavigationDrawerModule'
it requires MaterialNavigationDrawerModule project to build. Go to New > Import Module and import MaterialNavigationDrawerModule.
Update build.gradle in MaterialNavigationDrawer\app to
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "it.neokree.materialnavigationdrawer"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
buildTypes {
release {
//runProguard false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile project(':MaterialNavigationDrawerModule')
}
Update build.gradle in MaterialNavigationDrawer\MaterialNavigationDrawerModule to
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName 'dev'
}
buildTypes {
release {
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.balysv:material-ripple:1.0.1'
}
In MainActivity i deleted missing import
and rewrite Intent
to
Now it's working.
Android Studio is giving this error while compiling the project. I have searched and found that this may happen because of
android
Block in top of the build.gradle.But in my build.gradle it may be not the problem.
here is my gradle files.
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
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
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 19
}
dependencies {
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ptrprograms.chromecast"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:mediarouter-v7:19.0.+'
compile 'com.google.android.gms:play-services:6.1.11'
}
You're using Gradle domain-specific language (DSL) defined in the Android plugin before applying that plugin.
Remove the
android {
compileSdkVersion 19
}
in your top-level build.gradle. You already have compileSdkVersion 20 in your app build.gradle file where it actually matters.
now its showing "Error:(16, 0) Gradle DSL method not found: 'runProguard()'
runProguard was renamed to minifyEnabled in the Android Gradle plugin some time ago. You should rename it in your build script as well.
Not Solved:
I'm using gradle-experimental for doing NDK stuff.
Error:(13, 0) Dexcount plugin requires the Android plugin to be configured
MY Top level build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.4.0'
}
}
allprojects {
repositories {
jcenter()
}
}
So I'm working on project in AndroidStudio 0.8.1 beta and I want to make use of a library I found on github (https://github.com/derekbrameyer/android-betterpickers). I add the dependency like it says inside the README.md but when I try to sync the project with the gradle files it says:
Failed to find: com.doomonafireball.betterpickers:library:1.5.2
Here is my build.gradle file:
apply plugin: 'com.android.application'
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
}
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'gtsarandum.syncc'
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:19.+'
compile project(':extendedCalendarView')
compile project(':src')
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
compile 'com.github.gabrielemariotti.cards:library-extra:1.7.3'
compile 'com.doomonafireball.betterpickers:library:1.5.2'
}
Last time I had this problem with gabriellemariotti.cards:libraryd:1.7.3 I added maven { url 'http://repo1.maven.org/maven2' } inside the buildscript as you can see above.
Is there something else I have to add? If not, how do I solve this problem?
Many thanks in advance!
My fix was to add:
allprojects {
repositories {
mavenCentral()
}
}
to the build.gradle file
Try alter 'gradle.settings' with an include statement for the path/lib not being found.
Don't use HTTP Proxy. Android Studio -> File -> Settings-> HTTP Proxy -> No proxy
Using Android Studio 0.4.6
I've got the following gradle.build file:
apply plugin: 'android'
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.my.products.aproduct:aproduct.sdk.java:1.0.1-SNAPSHOT'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
The jar is not found when building the project:
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.my.products.aproduct:aproduct.sdk.java:1.0.1-SNAPSHOT.
Required by:
sva.frontend.android.jpurse:app:unspecified
Although I can find the jar and pom file in my local repository (~/.m2) folder. I've checked the maven settings of android studio and they've added a local repository pointing to ~/.m2/repositories
I've also tried adding mavenLocal() and even a hardcoded path to the repository in my gradle file.
I have no clues anymore on what might be wrong ?
You are putting mavenLocal() in the wrong place.
buildscript {
repositories {
mavenCentral()
}
dependencies {
//use your version
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
mavenLocal()
}
Also I suggest you updating your AS version to the last release (0.5.7)