instr rul txt gin 通过 ini .com org top
通过android studio新建一个空项目。在新建完项目之后,gradle编译会报错。
发生问题的原因是build.gradle(Project:TopDialog)中:
- allprojects {
- repositories {
- jcenter()
- }
- }
- jecnter()需要下载junit的依赖,但是被墙了(网上博客如是说),所以关于junit的部分会报错。
解决方法一:注释掉build.gradle(Module:app)的关于junit test的代码:
- apply plugin: ‘com.android.application‘
- android {
- compileSdkVersion 26
- buildToolsVersion "26.0.0"
- defaultConfig {
- applicationId "com.example.topdialog"
- minSdkVersion 15
- targetSdkVersion 26
- versionCode 1
- versionName "1.0"
- // testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
- }
- }
- }
- dependencies {
- compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])
- // androidTestCompile(‘com.android.support.test.espresso:espresso-core:2.2.2‘, {
- // exclude group: ‘com.android.support‘, module: ‘support-annotations‘
- // })
- compile ‘com.android.support:appcompat-v7:26.0.0-alpha1‘
- // testCompile ‘junit:junit:4.12‘
- }
解决方法二,修改build.gradle(Project:TopDialog),注释掉jcenter(),添加如下一段话(不过亲测编译会很慢):
- allprojects {
- repositories {
- // jcenter()
- maven { url "http://repo1.maven.org/maven2" }
- }
- }
Android开发之新建项目报错的问题
来源: http://www.bubuko.com/infodetail-2330382.html