无法为参数找到方法multiDexEnabled()

时间:2015-09-24 14:03:25

标签: android eclipse gradle

我的环境如下:

Eclipse:Luna Service Release 2 (4.4.2) with Gradle IDE Pack 3.6.x + 0.17 plugin
Android SDK: Androd 5.1.1 (API level 22)

我在Eclipse中为现有的android项目生成了Gradle构建文件。并更改build.gradle,如下所示,以便执行MultiDex。

apply plugin: 'android'

buildscript {
    repositories {
      mavenCentral()
    }
    dependencies {
      classpath 'com.android.tools.build:gradle:1.0.0'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':design')
    compile project(':materialish-progress')
    compile project(':PhotoView-AndroidLibrary')
    compile project(':pulltorefresh')
    compile project(':sweet-alert-dialog-library')
    compile project(':viewpager_indicator_AndroidLibrary')
    compile project(':Volley')
    compile project(':android-support-v7-appcompat')
    compile 'com.android.support:multidex:1.0.0'
}

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        multiDexEnabled true
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src','.apt_generated']
            resources.srcDirs = ['src','.apt_generated']
            aidl.srcDirs = ['src','.apt_generated']
            renderscript.srcDirs = ['src','.apt_generated']
            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')
    }
}

我还在应用程序中添加以下编码如下:

@Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

但是当我运行gradle build时,&#34;找不到方法multiDexEnabled()&#34;错误发生。我搜索了很多解决方案,但没有工作。任何人都可以帮忙吗?谢谢!

E:\workspace3\dianzi-Android>gradle build

FAILURE: Build failed with an exception.

* Where:
Build file 'E:\workspace3\dianzi-Android\build.gradle' line: 31

* What went wrong:
A problem occurred evaluating project ':dianzi-Android'.
> Could not find method multiDexEnabled() for arguments [true] on ProductFlavorD
sl_Decorated{name=main, minSdkVersion=ApiVersionImpl{mApiLevel=14, mCodename='nu
ll'}, targetSdkVersion=ApiVersionImpl{mApiLevel=22, mCodename='null'}, renderscr
iptTargetApi=-1, renderscriptSupportMode=null, renderscriptNdkMode=null, version
Code=-1, versionName=null, applicationId=null, testApplicationId=null, testInstr
umentationRunner=null, testHandleProfiling=null, testFunctionalTest=null, signin
gConfig=null, resConfig=null}.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED 

0 个答案:

没有答案