gpt4 book ai didi

java - 在 Jitpack 的脚本中,所有 buildscript {} block 必须出现在任何插件 {} block 之前

转载 作者:行者123 更新时间:2023-12-04 23:54:51 29 4
gpt4 key购买 nike

我正在尝试使用 jitpack 发布我的 android 库。但是获取 buildscript {} block 必须出现在任何插件 {} block 错误之前。我已经提到过这个问题:Getting 'buildscript {} blocks must appear before any plugins {} blocks' error in jitpack但没有找到任何解决方案。

错误:

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

这是我的项目级 gradle 的样子:

// 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
}

这是我的应用级别 gradle 的样子:

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'
}

我的 gradle 版本是 7.0.2。

我很确定这个 block 导致了错误:(在项目级 gradle 中)

plugins {
id "com.jfrog.bintray" version "1.8.4"
}

我无法将其移动到应用级别的 gradle。

最佳答案

我也有同样的问题,我只是像这样更改build.gradle项目中的位置:

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
}

关于java - 在 Jitpack 的脚本中,所有 buildscript {} block 必须出现在任何插件 {} block 之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69386231/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com