I recently added Kotlin to my Java project, my build started failing, and I am getting this message:
"only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed" and this "Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:"
Does anyone have any idea how to fix this? I have my jdk set as 1.8 (as you see below), so the existing answer to this question does not seem to apply.
compileOptions {
sourceCompatibility '1.8'
targetCompatibility '1.8'
}
As for the brackets, here's my project build.gradle file where it's referencing.
buildscript {
repositories {
jcenter()
google()
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.5'
}
}
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.70'
}
I guess I'm at the bleary eyed stage of the day. I moved it before allprojects and it worked. This was helpful:
only build script and other plugins script blocks are allowed before plugins
Related
I want to install the gradle plugin version 7.6
but I get this Error :
Could not determine the dependencies of task ':path_provider_android:test'.
Could not create task ':path_provider_android:testProfileUnitTest'.
this and base files have different roots: E:\flutter downloader the main program\flutterdownloaderthemainprogram\build\path_provider_android and C:\Users\Gcc\Downloads\Compressed\flutter_windows_3.3.0-stable\flutter.pub-cache\hosted\pub.dartlang.org\path_provider_android-2.0.22\android.
this is the build.gradle:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I use the java19
I try java17 and java11
I tried diffrent version of the gradle but I get the same Error
-go to the project terminal (ctrl+j in vscode) and run flutter clean
-go to the android folder and delete the .gradle folder
-run flutter pub get
-run flutter run
An error occurs during build:
Gradle sync failed: Could not get unknown property 'build' for root project 'Svetofor' of type org.gradle.api.Project.
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'build' for root project 'Svetofor' of type org.gradle.api.Project.
at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
at org.gradle.groovy.scripts.BasicScript$ScriptDynamicObject.getMissingProperty(BasicScript.java:157)
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
at org.gradle.groovy.scripts.BasicScript.getProperty(BasicScript.java:66)
at build_cn9w26wxe6fc7p57z1l3a9w12.run(C:\Users\acosm\AndroidStudioProjects\Svetofor\build.gradle:1)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 164 more
build.gradle (Svetofor) :
build.gradle(Project: AndroidStudioProjects)
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
buildscript {
repositories {
google()
mavenCentral()
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
dependencies {
classpath 'com.android.tools.build:gradle:3.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Remove first line. you dont need this build.gradle(Project: AndroidStudioProjects)
There's a Java file I'm meant to convert to Kotlin. I'm stuck with this Gradle problem and can't find my way around it. What can I do to resolve this issue?
Go to build.gradle(Module)
and inside dependencies add the following line.
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
It should look something like this
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I run my App, AS comes up with this error. Says that the file was not found at https://repo.jfrog.org/artifactory/libs-release-bintray/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar?referrer. Please help! Putting google() repo doesn't work.
I ran into this issue as well. Basically, the issue is that mentioned jar file is no longer in jcenter. I resolved by changing the order of search in our app build.gradle:
buildscript {
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I'm using Intellij IDEA 2017.2.4 and Gradle 4.0.1
I have few Spring Boot services. And I facing a problem to run them, they can fail while starting in a random way because of missing dependencies.
I have a parent project with build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://plugins.gradle.org/m2/" }
mavenLocal()
}
dependencies {
classpath("io.spring.gradle:dependency-management-plugin:$dependencyManagementPluginVersion")
classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'idea'
group = '***'
version = '***'
}
subprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8
processResources {
filesMatching('**/*.yml') {
expand(project.properties)
}
}
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion")
mavenBom("org.springframework.boot:spring-boot-dependencies:$springBootVersion")
}
dependencies {
dependency "com.google.cloud:google-cloud-storage:$googleCloudStorageVersion"
...
dependency "org.junit.jupiter:junit-jupiter-api:$junitVersion"
}
}
}
And a child project build.gradle:
apply plugin: 'org.springframework.boot'
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
mavenLocal()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
...
testCompile('com.h2database:h2')
}
In some cases lombok dependency is missed, in other javax dependency. It shows that dependencies are not there.
But after I press Refresh All Gradle Projects and build once again it works.
Maybe someone encountered the same issue and have some solution for it?
It seems that you have problem with lombok dependency. First step is to ensure that lombok is added as your compile time dependency for example:
repositories {
mavenCentral()
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.16.18'
}
Second step is to ensure that you have newest lombok plugin installed on your Intellij. It is very important when you are trying to compile your project inside IDE. Another thing that may help is setting to autoupdate dependencies in Intellij configuration.