当我使用Android Studio根据Official Documentation创建新项目时,在编译项目时会发生一些错误:
错误图片:
我从未编辑过有关gradle或其他文件的任何配置,这是日志文件:
2018-11-19 20:33:08,967 [d thread 3] INFO - e.project.sync.GradleSyncState - Started setup of project 'MyFirstApp'.
2018-11-19 20:33:08,976 [e-1136-b06] INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SETUP_STARTED
2018-11-19 20:33:09,534 [d thread 3] INFO - e.project.sync.GradleSyncState - Gradle sync failed (1 m 17 s 461 ms)
2018-11-19 20:33:09,604 [e-1136-b06] INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender deactivation event: SYNC_FINISHED
2018-11-19 20:33:09,604 [e-1136-b06] INFO - idea.project.IndexingSuspender - Finishing batch update for project: Project '/Users/tanrui/AndroidStudioProjects/MyFirstApp' MyFirstApp
2018-11-19 20:33:09,657 [cessToken]] INFO - pl.ProjectRootManagerComponent - project roots have changed
2018-11-19 20:33:09,832 [d thread 2] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 1ms; general responsiveness: ok; EDT responsiveness: ok
2018-11-19 20:33:10,620 [d thread 2] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 788ms; general responsiveness: ok; EDT responsiveness: ok
2018-11-19 20:33:10,622 [d thread 2] INFO - #com.jetbrains.cidr.lang - Clearing symbols finished in 0.001 s.
2018-11-19 20:33:10,622 [d thread 2] INFO - #com.jetbrains.cidr.lang - Building symbols in FAST mode, 0 source files from total 0 project files
2018-11-19 20:33:10,623 [d thread 2] INFO - #com.jetbrains.cidr.lang - Loading symbols finished in 0.001 s.
2018-11-19 20:33:10,624 [d thread 2] INFO - #com.jetbrains.cidr.lang - Loading Header Maps finished in 0.000 s.
2018-11-19 20:33:10,624 [d thread 2] INFO - #com.jetbrains.cidr.lang - Loading Module Maps finished in 0.000 s.
2018-11-19 20:33:10,624 [d thread 2] INFO - #com.jetbrains.cidr.lang - Saving Module Maps finished in 0.000 s.
2018-11-19 20:33:10,625 [d thread 2] INFO - #com.jetbrains.cidr.lang - Loaded 0 tables for 0 files (0 project files)
2018-11-19 20:33:10,625 [d thread 2] INFO - #com.jetbrains.cidr.lang - Building symbols for 0 source files
2018-11-19 20:33:10,630 [d thread 2] INFO - #com.jetbrains.cidr.lang - Building symbols for 0 unused headers
2018-11-19 20:33:10,632 [d thread 2] INFO - #com.jetbrains.cidr.lang - Building symbols finished in 0.007 s.
2018-11-19 20:33:10,632 [d thread 2] INFO - #com.jetbrains.cidr.lang - Saving modified symbols for 0 files (0 tables of total 0)
2018-11-19 20:33:10,633 [d thread 2] INFO - #com.jetbrains.cidr.lang - Saving symbols finished in 0.001 s.
2018-11-19 20:33:11,138 [d thread 1] INFO - CompilerWorkspaceConfiguration - Available processors: 4
2018-11-19 20:34:01,446 [e-1136-b06] INFO - ntellij.util.proxy.CommonProxy - <html>You have JVM property "https.proxyHost" set to "127.0.0.1".<br>This may lead to incorrect behaviour. Proxy should be set in Settings | HTTP Proxy<br>This JVM property is old and its usage is not recommended by Oracle.<br>(Note: It could have been assigned by some code dynamically.)
Google上也有许多类似的问题,因为他们说我应该为Android Studio设置代理(也许仅在CN中需要)。实际上,我已经正确设置了ShadowSocks并按如下所示配置Android Studio:
代理配置图片:
测试代理图片:
测试成功图片:
但是它仍然不起作用。
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
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.2.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
}
build.gradle(模块):
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "top.guitoubing.myfirstapp"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
}
如果任何人都知道问题出在哪里,请给我一个建议,或者如果我有任何不清楚的地方,请向我提问。 希望对您有所帮助!谢谢。