在app目录下build.gradle中引用了第三方类库,gradle编译时不断报错,无法resolve第三方类库,或者无法download第三方类库
dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'io.reactivex.rxjava2:rxjava:2.1.14' implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'com.squareup.retrofit2:adapter-rxjava:2.4.0' implementation 'com.squareup.okhttp3:okhttp:3.10.0' }
上网查询可能是网络原因,解决办法如下:
1. 检查网络连接是否正常,正常继续往下执行步骤2
2.关闭所有Android Studio项目并且重启Android Studio
3.重新打开刚才gradle编译出错的项目然后重新编译gradle,编译通过,解决该问题