Я взял чужой проект и хочу его запустить у себя в Andorid Studio, но на стадии сборки получаю такую ошибку.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Basic_Calculator-task:compileDebugJavaWithJavac'.
> Failed to query the value of task ':Basic_Calculator-task:compileDebugJavaWithJavac' property 'options.generatedSourceOutputDirectory'.
> Querying the mapped value of map(java.io.File property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, F:\Android\Basic Calculator\Basic Calculator\task\build\generated\ap_generated_sources\debug\out)) org.gradle.api.internal.file.DefaultFilePropertyFactory$ToFileTransformer@799883b2) before task ':Basic_Calculator-task:compileDebugJavaWithJavac' has completed is not supported
With --info.
> Task :Basic_Calculator-task:javaPreCompileDebug UP-TO-DATE
Task :Basic_Calculator-task:javaPreCompileDebug in Basic_Calculator-task Starting
Caching disabled for task ':Basic_Calculator-task:javaPreCompileDebug' because:
Build cache is disabled
Skipping task ':Basic_Calculator-task:javaPreCompileDebug' as it is up-to-date.
Task :Basic_Calculator-task:javaPreCompileDebug in Basic_Calculator-task Finished
:Basic_Calculator-task:javaPreCompileDebug (Thread[Execution worker for ':',5,main]) completed. Took 0.001 secs.
Но, если я создаю собственный проект таких проблем нет.
gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "org.hyperskill.calculator"
minSdkVersion 21
// DO NOT CHANGE THIS VALUE
// Because this version related with robolectic version too
// [Robolectric] WARN: Android SDK 29 requires Java 9. Tests won't be run on SDK 29 unless explicitly requested.
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "com.edu.AndroidEduTestRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
def material = "1.3.0-beta01"
implementation "com.google.android.material:material:$material"
def espressoCore = "3.3.0"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCore"
def testRules = "1.3.0"
androidTestImplementation "androidx.test:rules:$testRules"
def extJUnit = "1.1.2"
androidTestImplementation "androidx.test.ext:junit:$extJUnit"
// Robolectric
// http://robolectric.org
def robolectric = "4.3.1"
testImplementation "org.robolectric:robolectric:$robolectric"
}
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
afterEvaluate {
if (extensions.findByName("android") != null) {
android {
testOptions {
unitTests {
includeAndroidResources = true
all {
afterTest { TestDescriptor test, TestResult result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
def message = result.exception?.message ?: "Wrong answer"
def lines = message.readLines()
println "#educational_plugin FAILED + " + lines[0]
lines.subList(1, lines.size()).forEach { line ->
println "#educational_plugin" + line
}
// we need this to separate output of different tests
println()
}
}
}
}
}
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
С этой темой, я уже ознакомился и мне ничего не помогло, я пролистал много сайтов в процессе поиска ответа, я обращаюсь к вам после трех дней поиска решения проблемы.
JavaVersion.VERSION_1_7
укажитеJavaVersion.VERSION_1_8
. Также проверьте в настройках студии, что она использует 8, а не 9 (или 11) Java. Если не 8 - установите оную и укажите в студии. Также можно попроовать поставить более старую версию студии или перестановить имеющуюся. Ещё InvalidateCacheAndRestart выполнить можно попробовать.