我尝试通过直接通过android studio下载GridLayout来实现GridLayout,但出现此错误:
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download gridlayout.aar (androidx.gridlayout:gridlayout:1.0.0)
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download gridlayout.aar (androidx.gridlayout:gridlayout:1.0.0)
Show Details
Affected Modules: app
我已经尝试将Global Gradle设置设置为脱机工作,但是会显示新错误
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not download gridlayout.aar (androidx.gridlayout:gridlayout:1.0.0): No cached version available for offline mode
Disable offline mode and sync project
Show Details
Affected Modules: app
GridLayout尚不适用于Android Studio吗?
这是我的Gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.android.guessit"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Glide maybe later add code to proguard
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
// circle imageview
implementation 'de.hdodenhof:circleimageview:3.0.0'
// cardview
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
}
答案 0 :(得分:0)
据我从警告中看到的,gridlayout lib没有什么错。如果您希望它正常工作,则需要从Android Studio中禁用离线工作。为了禁用它,请按照下列步骤操作:
“ Gradle处于离线模式,这意味着它将不会通过网络来解决依赖关系。请转到“偏好设置”>“构建,执行,部署”>“ Gradle”,然后取消选中“离线工作”。在Android Studio中,打开设置并搜索离线,它将找到包含离线工作的Gradle类别。您可以在此处将其禁用。”
然后,您可以使用网格布局
<androidx.gridlayout.widget.GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
请通过评论让我知道它是否无效。