After the plug-in update?, the build has not been successfully.
The source is the same as the code in the Kotlin start book.(Contents up to 250 pages)
I wanted to try various things in REPL, so I created the file below.
kotlin:sample.kt
package com.se.testuser.qitacliant
US>class sample {
// method that might return null
funreturnNullableStr(arg:String): String?{
if(arg=="null") return null
return "not null"
}
// method that does not return null
funreturnNotNullStr(arg:String): String {
return "not null"
}
}
It appears as follows, so
I clicked on the restart part and built it again.
You're running the REPL with updated classes: Build module 'app' and restart
Then I got the following error.
Error: Gradle: A problem occurred configuring root project 'QiitaCliant'.
>Could not resolve all files for configuration ':classpath'.
>Could not find com.android.tools.build:gradle: 3.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
Required by:
project:
Build > Rebuild Project will complete successfully.
Information: Gradle Task [clean,:app:assemblyDebug]
C:\Users\testuser\AndroidStudioProjects\QiitaCliant\app\src\main\kotlin\com\se\testuser\qiitacliant\sample.kt
Warning: (15,26) Parameter 'arg' is never used
Information: BUILD SUCCESSFUL in 41s
Informational: 0 errors
information:one warning
information:See full console output
I can see from the error message that I can't find the following two, but where should I add the settings?
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
Also include the contents of build.gradle.
build.gradle (project root)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
jcenter()
}
dependencies {
classpath'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they Belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean (type: Delete) {
delete rootProject.buildDir
}
build.gradle (app route)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android{android{
compileSdkVersion25
buildToolsVersion "26.0.2"
// Add Configuration From Here
sourceSets{
// This is for testing purposes.
main.java.srcDirs+='src/androidTest/kotlin'
androidTest.java.srcDirs+='src/main/kotlin'
}
// Add Configuration Up to here
defaultConfig {
applicationId "com.se.testuser.qitacliant"
minSdkVersion21
targetSdkVersion25
versionCode1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
miniEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compilefileTree (dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espreso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile'com.android.support:appcompat-v7:25.3.1'
compile'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
mavenCentral()
}
Self-resolved.
We were able to correct the error by doing the following.
© 2024 OneMinuteCode. All rights reserved.