Reputation: 137
I am trying to publish my android library with jitpack. But getting buildscript {} blocks must appear before any plugins {} blocks error.
I have already referred to this question : Getting 'buildscript {} blocks must appear before any plugins {} blocks' error in jitpack but did not found any solution.
Error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/jitpack/build/build.gradle' line: 26
* What went wrong:
Could not compile build file '/home/jitpack/build/build.gradle'.
> startup failed:
build file '/home/jitpack/build/build.gradle': 26: all buildscript {} blocks must appear before any plugins {} blocks in the script
See https://docs.gradle.org/7.0.2/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
@ line 26, column 1.
buildscript {
^
1 error
This is what my project level gradle looks like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.jfrog.bintray" version "1.8.4"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is what my app level gradle looks like:
plugins {
id 'com.android.application'
id "com.jfrog.bintray"
}
android {
compileSdk 30
defaultConfig {
applicationId "com.siddydevelops.logutil"
minSdk 23
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
My gradle version is 7.0.2.
I am pretty sure that this block is causing the error: (in project level gradle)
plugins {
id "com.jfrog.bintray" version "1.8.4"
}
I cant move it to app level gradle.
Upvotes: 5
Views: 7367
Reputation: 91
i have the same problem too, i just change the position inside build.gradle project like this:
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
}
}
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Upvotes: 9