0

enter code hereunable to fix the project , new to android studio , need help fixing gradle my gradle file ,happening when i import projects from eclipse, exporting done fine

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}
apply plugin: 'com.android.application'

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile project(':ksoap2-android-assembly-2.5.8-jar-with-dependencies')
}

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.1"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')

        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

and the error i am getting is

Error:Configuration with name 'default' not found.

changed code \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

 buildscript {
                repositories {
                    jcenter()
                }
                dependencies {
                    classpath 'com.android.tools.build:gradle:1.2.3'
                }
            }
            android {
                compileSdkVersion 23
                buildToolsVersion "23.0.1"

                defaultConfig {
                    applicationId "com.package.name"
                    minSdkVersion 11
                    targetSdkVersion 23
                    versionCode 1
                    versionName "1.0"
                }
                buildTypes {
                    release {
                        minifyEnabled false
                        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                    }
                }
            }
            apply plugin: 'com.android.application'

            dependencies {
                compile fileTree(include: '*.jar', dir: 'libs')
                compile project(':ksoap2-android-assembly-2.5.8-jar-with-dependencies')
            }

            android {
                compileSdkVersion 23
                buildToolsVersion "23.0.1"

                defaultConfig {
                    applicationId "com.package.name"
                    minSdkVersion 11
                    targetSdkVersion 23
                    versionCode 1
                    versionName "1.0"
                }
                buildTypes {
                    release {
                        minifyEnabled false
                        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                    }
                }

                sourceSets {
                    main {
                        manifest.srcFile 'AndroidManifest.xml'
                        java.srcDirs = ['src']
                        resources.srcDirs = ['src']
                        aidl.srcDirs = ['src']
                        renderscript.srcDirs = ['src']
                        res.srcDirs = ['res']
                        assets.srcDirs = ['assets']
                    }

                    // Move the tests to tests/java, tests/res, etc...
                    instrumentTest.setRoot('tests')

                    // Move the build types to build-types/<type>
                    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
                    // This moves them out of them default location under src/<type>/... which would
                    // conflict with src/ being used by the main source set.
                    // Adding new build types or product flavors should be accompanied
                    // by a similar customization.
                    debug.setRoot('build-types/debug')
                    release.setRoot('build-types/release')
                }

            }
Krishna Avadhanam
  • 88
  • 1
  • 1
  • 10
  • this is usually a project settings.gradle error - most likely gradle can't find one of the dependencies there or a dependency in build.gradle because the settings is missing the proper reference to it. Post settings.gradle – Jim Nov 26 '15 at 05:56
  • Have you checked this? http://stackoverflow.com/questions/17188489/android-studio-gradle-configuration-with-name-default-not-found http://stackoverflow.com/questions/22743582/error-configuration-with-name-default-not-found-in-android-studio – Swapnil Chaudhari Nov 26 '15 at 05:57

1 Answers1

0

Add the defaultConfig into the android block

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.package.name"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

EDIT 1 : The android part of your gradle file should be inside the applications build.gradle not in the projects root gradle

There are two gradle files

Here is a sample Root Project Gradle file

// 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:2.0.0-alpha1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Sample Module Gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.package.name"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.android.support:cardview-v7:23.1.1'
}
Gowtham Raj
  • 2,795
  • 1
  • 19
  • 38