My environment is as below:
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)
I generated Gradle build files for existing android project in Eclipse. And change build.gradle as below in order to do 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')
}
}
I also add below coding in the application as below:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
But when I run gradle build, "Could not find method multiDexEnabled()" error happens. I have searched lots of solution, but not work. Any one can help? Thanks!
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