Gradle Android Project opens Multidex

Source: Internet
Author: User
Tags manual

Environment Gradle 2.2 (if the version is different. The following script needs to adjust the Com.android.tools.build:gradle version number)


Build.gradle (note the place marked red)

Buildscript {repositories {mavencentral ()} dependencies {classpath ' Com.android.tools.buil D:gradle:0.14.+ '} tasks.withtype (javacompile) {options.encoding = ' UTF-8 '}} Apply plugin: ' Android ' Dependenc ies {compile filetree (dir: ' Libs ', include: ' *.jar ')} android {compilesdkversion buildtoolsversion "21. 1.1 "Lintoptions {Abortonerror false} compileoptions {sourcecompatibility javaversion.version_1_6 targetCom 
	Patibility Javaversion.version_1_6} defaultconfig {minsdkversion targetsdkversion = True } 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 builds 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 is accompanied//by a similar customization.
			Debug.setroot (' Build-types/debug ') release.setroot (' Build-types/release ')} signingconfigs {release { StoreFile file ("Talkwebmbi.keystore") storepassword "* * *" keyalias "* * *" keypassword "* * *"} dexoption 
		   s {predexlibraries = false} afterevaluate {tasks.matching {it.name.startsWith (' dex ')}.each {dx-> if (dx.additionalparameters = = null) {dx.additionalparameters = ['--multi-dex ']} else {dx.addition
Alparameters + = '--multi-dex '}}	 }//Declare that the build is required to run Proguard buildtypes {release {minifyenabled true proguardfile getdefaultproguardfile ('
 Proguard-android.txt ') proguardfile ' proguard.cfg ' Signingconfig Signingconfigs.release}}}

Proguard.cfg

# This is a configuration the file for Proguard. # Http://proguard.sourceforge.net/index.html#manual/usage.html-dontusemixedcaseclassnames- Dontskipnonpubliclibraryclasses-verbose # optimization is turned from default.  Dex does not like code run # through the Proguard optimize and preverify steps (and performs some
On its own). #-dontoptimize-dontpreverify #-dontshrink # If You are want to enable optimization, you should include the # following: #-op Timizations!code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* #- Optimizationpasses 5 #-allowaccessmodification #-dontpreverify # # Note ' You cannot just include the flags in your own # configuration file; If you are are including this file, optimization # is turned off. You'll need to either edit this file, or # Duplicate the contents of this file and remove the include of this # file from
Your project ' s Proguard.config path property. -keepattributes Innerclasses-keepattribUtes signature-keepattributes *annotation*-keep @interface *-keep enum * {*;} # Android:-keep public class * extends Android.app.activity-keep public class * extends Android.app.application-keep PU  Blic class * Extends Android.app.service-keep public class * extends Android.content.broadcastreceiver-keep public class * Extends Android.content.contentprovider-keep public class * extends Android.app.backup.backupagent-keep public class  * Extends android.preference.Preference #-keep public class * Extends android.support.v4.app.Fragment #-keep public class * Extends Android.app.fragment-keep public class Com.android.vending.licensing.ILicensingService # for native methods, Http://proguard.sourceforge.net/manual/examples.html#native-keepclasseswithmembernames class * {native <meth
ods>;
    }-keep public class * extends Android.view.View {public <init> (android.content.Context); Public <init> (Android.content.Context, Android.util.AttributeSet);
    Public <init> (Android.content.Context, android.util.AttributeSet, int);
public void set* (...);

}-keepclasseswithmembers class * {public <init> (Android.content.Context, android.util.AttributeSet);}

-keepclasseswithmembers class * {public <init> (Android.content.Context, android.util.AttributeSet, int);}

-keepclassmembers class * extends android.app.Activity {public void * (Android.view.View);} # for enumeration classes, Http://proguard.sourceforge.net/manual/examples.html#enumerations-keepclassmembers
    Enum * {public static **[] values ();
public static * * VALUEOF (java.lang.String);
  }-keep class * Implements android.os.Parcelable {public static final android.os.parcelable$creator *;
<init> (Android.os.Parcel); }-keepclassmembers Class * *.

r$* {public static <fields>;}
# The Support library contains references to newer platform versions. # Don ' t warn about those in the case this app was linking against an OLDer # Platform version.
We know about them, and they are safe. -dontwarn android.support.**-dontwarn javax.xml.**-keep class * extends Java.util.ListResourceBundle {protected Object [] [] getcontents ();
 #------------LIBS---------------------keep class android.support.** {public *;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.