gpt4 book ai didi

android-studio - 如何在Android Studio中使用新的Gradle实验版

转载 作者:行者123 更新时间:2023-12-03 04:35:50 25 4
gpt4 key购买 nike

我使用Android Studio NDK创造了一个非常好的世界。按照http://tools.android.com/tech-docs/new-build-system/gradle-experimental的指示,我复制了完全相同的文件(仅保留了一些较新的构建工具版本),但始终出现错误:
错误:(49,1)评估项目':app'时发生问题。

Could not find method testCompile() for arguments [junit:junit:4.12] on project ':app'.



您能告诉我HelloWorld问题吗?
这是我的应用程序build.gradle
 apply plugin: "com.android.model.application"

model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig.with {
applicationId = "com.android.services.testjni"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
buildConfigFields.with {
create() {
type = "int"
name = "VALUE"
value = "1"
}

}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file("proguard-rules.pro"))
}
}
android.productFlavors {
create("flavor1") {
applicationId = "com.app"
}
}
// Configures source set directory.
android.sources {
main {
java {
source {
srcDir "src"
}
}
}
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}

和build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle-experimental:0.2.1"

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

和gradle-wrapper.properties
#Fri Nov 27 17:00:16 ICT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip

最佳答案

AFAIK,android插件没有testCompile配置,它是gradle的java插件中的一种,但是具有androidTestCompile。因此,您必须在依赖项中将其重命名为:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}

关于android-studio - 如何在Android Studio中使用新的Gradle实验版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33978366/

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