摇篮DSL找不到方法:“multiDexEnabled';使用的gradle不包含的方法 [英] Gradle DSL Method not found: 'multiDexEnabled'; using gradle that does not contain the method
问题描述
这个问题已经被问过,但我仔细遵循的方向和至今还在领受这个问题。我需要一些帮助,首先要弄清楚什么,我用我的特殊情况丢失。这里是我做了什么。
Android的支持 - multidex.jar添加到预计的libs文件夹: 1)加入Android的支持,multidex.jar
2)编辑项目的build.gradle:我修改位于我的项目的文件夹我的build.gradle文件。
应用插件:'机器人'依赖{
编译文件树(导演:'库',包括:的* .jar)
.....
编译com.android.support:multidex:1.0.0
}安卓{
compileSdkVersion 19
buildToolsVersion21.1.2 defaultConfig {
的applicationIDcom.example.mypackagename
14的minSdkVersion
targetSdkVersion 21 //启用multidex支持。
multiDexEnabled真
} buildTypes {
发布 {
runProguard假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard的-rules.txt
}
} sourceSets {
主要{
manifest.srcFile'的AndroidManifest.xml
java.srcDirs = ['src'中]
resources.srcDirs = ['src'中]
aidl.srcDirs = ['src'中]
renderscript.srcDirs = ['src'中]
res.srcDirs = ['水库']
assets.srcDirs = ['资产']
} //移动测试,测试/ JAVA,测试/ RES等...
instrumentTest.setRoot(测试) //移动构建类型构建类型/<&型GT;
//例如,建立类型/调试/ JAVA,内置类型/调试/ AndroidManifest.xml中,...
//这个动作出来在src / LT他们默认位置和的;类型> / ...这将
//与SRC /冲突正在使用的主要来源集。
//添加新的构建类型或产品的口味应该陪同
//通过类似定制。
debug.setRoot(集结类型/调试)
release.setRoot(集结类型/释放)
}
}
3)修改项目中的应用类:我有一个扩展应用程序的类。我增加了以下到它。
@覆盖
保护无效attachBaseContext(上下文基地){
super.attachBaseContext(基峰);
MultiDex.install(本);
}
这原本是一个Eclipse项目。我出口Eclipse项目,然后导入Android Studio中的的build.gradle文件。我一直没能成功运行,因为该项目。与我错过了将AP preciated步骤任何帮助。在此先感谢!
编辑:这是我的顶层构建文件的内容
//顶级构建文件,您可以添加常用的配置选项,所有分项目/模块。
buildscript {
库{
mavenCentral()
}
依赖{
类路径'com.android.tools.build:gradle:0.12.+
}
}
替换为:
类路径com.android.tools.build:gradle:0.12.+
与
类路径com.android.tools.build:gradle:1.0.0
作为multidex支持未在摇篮中,有7个月大的beta版本为Android插件提供的。
This question has been asked before, however, I have followed the directions carefully and am still receiving this issue. I need some help with figuring out what I am missing with my particular situation. Here is what I have done.
1) Add android-support-multidex.jar: Added android-support-multidex.jar to projected libs folder 2) Edit project build.gradle: I modified my build.gradle file located in my project's folder.
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
.....
compile 'com.android.support:multidex:1.0.0'
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.mypackagename"
minSdkVersion 14
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
3) Modify Project Application class: I have a class that extends Application. I added the following to it.
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
This was originally an Eclipse project. I exported the Eclipse project, and then imported the build.gradle file in Android Studio. I have not been able to successfully run the project since. Any help with steps I have missed would be appreciated. Thanks in advance!
Edit: Here is the contents of my top-level build file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
Replace:
classpath 'com.android.tools.build:gradle:0.12.+'
with:
classpath 'com.android.tools.build:gradle:1.0.0'
as multidex support was not offered in that 7-month-old beta release of the Gradle for Android plugin.
这篇关于摇篮DSL找不到方法:“multiDexEnabled';使用的gradle不包含的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!