gpt4 book ai didi

android - 找不到参数[目录 'libs']的方法compile()

转载 作者:行者123 更新时间:2023-12-03 05:56:11 25 4
gpt4 key购买 nike

我将一个项目导入Android Studio的工作区中,并且该项目的文件结构似乎没有处于如图1所示的适当状态。

另外,当我尝试构建和编译项目时,收到以下错误:

Error:(20, 0) Could not find method compile() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
<a href="openFile:C:\Users\xxx\AndroidStudioProjects\MAN\build.gradle">Open File</a>

同样在项目中,build.gradle(project)存在两次,build.gradle(app)存在一次,如图2所示。

请查看下面的gradle文件,并让我知道如何更正此错误以及为什么得到此错误。

build.gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'android-apt'

def AAVersion = '3.2' // '4.2.0'

dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}

apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName 'eu.man.m24wsapp'
}
}

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
applicationId "eu.man.m24wsapp"

targetSdkVersion 25
minSdkVersion 10

versionCode 1
versionName "1.1.18"
}

signingConfigs {
release {
storeFile file("../wsapp.keystore")
storePassword "7s5zhgknsIXxHgw"
keyAlias "man_mobile24"
keyPassword "manmobile242014"
}
}

lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}

buildTypes {
release {
minifyEnabled false // 15.05.2017 avk, enables/disables proguard
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release

applicationVariants.all { variant ->
variant.outputs.each { output ->
def name = output.outputFile.name.replace("app", "Man");
name = name.replace(".apk", "-" + defaultConfig.versionName + "-" + defaultConfig.versionCode + ".apk");
output.outputFile = new File(output.outputFile.parent, name)
}
}
}
}

}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':appcompat')
compile project(':securepreferences')
compile 'com.android.support:support-v4:25.2.0' // .0.1

compile 'com.google.android.gms:play-services:4.3.23'
// compile 'com.google.android.gms:play-services-maps:10.0.1'
// compile 'com.google.android.gms:play-services-location:10.0.1'

// AVK 05.02.2017 compile 'com.github.chrisbanes.photoview:library:1.2.2'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
compile 'com.google.code.gson:gson:2.7' // 2.4

// AVK 5.2.2017 compile 'com.squareup:otto:1.3.6'
compile 'com.squareup:otto:1.3.8'

// AVK 5.2.2017 compile 'com.squareup.okhttp:okhttp:1.5.4'
// AVK 5.2.2017 compile 'com.squareup.okhttp:okhttp:2.5.0'
// AVK 5.2.2017 compile 'com.squareup.okhttp:okhttp:2.6.0' // oder
compile 'com.squareup.okhttp:okhttp:2.2.0' // 7.5' // oder
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0' // 7.5' // oder
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
// AVK 5.2.2017 compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'

compile 'com.squareup.picasso:picasso:2.4.0'
//compile 'com.squareup.picasso:picasso:2.2.0'
// AVK 5.3.2017 compile 'com.squareup.picasso:picasso:2.4.0'

// AVK 3.2.2017 compile 'com.squareup.retrofit:retrofit:1.5.1'
// AVK 3.2.2017 compile group: 'com.squareup.retrofit', name: 'retrofit', version: '1.9.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
// AVK 5.2.2017 compile 'com.squareup.retrofit2:retrofit:2.1.0'

}
**build.gradle(project)**:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7' // 1.8?
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('app/libs/android-viewbadger.jar')
compile files('app/libs/iDappsImagesLib_v0.2.jar')
compile files('app/libs/iDappsToolsLib_v0.1.jar')
compile files('gradle/wrapper/gradle-wrapper.jar')
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

图片1 :

enter image description here

图片2 :

enter image description here

image-3项目属性:

enter image description here

image-4 gradle路径:

enter image description here

最佳答案

将带引号的块从build.gradle(project)移至build.gradle(app),因为compileandroid来自application插件

build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7' // 1.8?
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}

build.gradle(app)
 dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('app/libs/android-viewbadger.jar')
compile files('app/libs/iDappsImagesLib_v0.2.jar')
compile files('app/libs/iDappsToolsLib_v0.1.jar')
compile files('gradle/wrapper/gradle-wrapper.jar')
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
dexOptions {
incremental true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

关于android - 找不到参数[目录 'libs']的方法compile(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44783742/

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