我刚刚安装了android studio并更新了sdk。我创建了一个新项目,但似乎没有编译。 gradle sync存在问题:
Error:(29, 0) Could not find method android() for arguments [build_st17khxxb7irr63f8isja72t$_run_closure4@3d9ba855] on root project 'MyApplication' of type org.gradle.api.Project.
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
一些无用的词,因为代码太多
这是build.gradle文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
ext {
compileSdkVersion = 22
buildToolsVersion = '25.0.1'
}
}
android{
compileSdkVersion 22
buildToolsVersion '25.0.1'
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
}
dependencies {
compile files('app/libs/junit-4.12-JavaDoc.jar')
}
答案 0 :(得分:0)
据我所知,你在谈论一个gradle构建问题。如果我理解正确,可以轻松解决。
粘贴在它下面的代码中:
compileSdkVersion 24
buildToolsVersion "23.0.3
那应该是这样的:
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
答案 1 :(得分:0)
Could not find method android() for arguments in Android Studio project
此链接将帮助您解决build.gradle问题。
答案 2 :(得分:0)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
}