我试图将GridLayout用作
GridLayout maingrid=(GridLayout)findViewById(R.id.mainGridView);
但是它使我的应用程序崩溃了。 上网冲浪解决该问题,我应该使用
android.support.v7.widget.GridLayout;
而不是android.widget.GridLayout;
,但是在使用此方法时出现错误无法解决v7。
搜索了此问题,并获得了许多解决方案来更新 build.gradle 文件,但该文件也因构建而失败。
build.gradle文件最初:
// 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
}
更新后:
// 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
}
}
请帮助我解决此问题
答案 0 :(得分:1)
您必须将它们添加到Project / app / build.gradle。
您必须将它们移动到{/ {1}}块中的Project / app / build.gradle:
dependencies