0

I tried to use GridLayout as

GridLayout maingrid=(GridLayout)findViewById(R.id.mainGridView);

But it was crashing my application. Surfing internet for the problem gave solution that i should use

android.support.v7.widget.GridLayout; 

instead of android.widget.GridLayout; but while using this i am getting error could not resolve v7.

Searched for this problem and got many solution to update build.gradle file but it also fails by build.

build.gradle file Initially:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        implementation 'com.android.support:cardview-v7:21.+'
        implementation 'com.android.support:recyclerview-v7:21.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

After updating:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:26.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.android.support:design:26.1.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26
    }
}

please help me in resolving this issue

1
  • maybe some of the java files contain android.support.v7.widget.GridLayout; import statement at the top try to remove them manually Commented Jul 26, 2019 at 15:04

1 Answer 1

1

You must not add dependencies to Project/build.gradle.

You must add them to the Project/app/build.gradle.

You must move these to Project/app/build.gradle, in the dependencies block:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.1'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.