Gradle Android 工程開啟 multiDex
環境 Gradle 2.2 (如果版本不同.下面的指令碼是需要調整 com.android.tools.build:gradle 這個版本號的)
build.gradle (注意標紅的地方)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.+'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled = 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 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')
}
signingConfigs {
release {
storeFile file("TalkwebMBI.keystore")
storePassword "***"
keyAlias "***"
keyPassword "***"
}
}
dexOptions {
preDexLibraries = false
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
//宣告此釋出構建在簽名之前需要執行proguard
buildTypes {
release {
minifyEnabled true
proguardFile getDefaultProguardFile('proguard-android.txt')
proguardFile 'proguard.cfg'
signingConfig signingConfigs.release
}
}
}
proguard.cfg
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
#-dontoptimize
-dontpreverify
#-dontshrink
# If you want to enable optimization, you should include the
# following:
#-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
#-optimizationpasses 5
#-allowaccessmodification
#-dontpreverify
#
# Note that you cannot just include these flags in your own
# configuration file; if you are including this file, optimization
# will be 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 public 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, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
-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, see 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 case this app is 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 *; }
相關推薦
Gradle Android 工程開啟 multiDex
環境 Gradle 2.2 (如果版本不同.下面的指令碼是需要調整 com.android.tools.build:gradle 這個版本號的)build.gradle (注意標紅的地方)buildscript { repositories { m
android studio 開啟multidex支援
Ref:http://www.cnblogs.com/chenxibobo/p/6076459.html app目錄下的build.gradle檔案: (1)在defaultConfig中新增multiDexEnabled true這個配置項。 (2)在depend
用Gradle命令行編譯Android工程
led app oid 錯誤 windows failure except per AI 在Android sdk 目錄下的samples/android-21/ 文件夾下,任找一個工程,如果在命令行直接編譯 可能會報這種錯誤:gradle buile.gradle FA
android studio開啟專案Gradle Download:https://jcenter載入慢
我們經常會遇到這個問題,下載了一個demo,但是gradle載入的時候特別慢,這個是因為很多要連線境外伺服器,所以網速慢的一筆,為解決這個問題,我這裡推薦兩種方法。 使用方法: build.gradle buildscript { repositories
AS-->如何用Gradle命令列,構建Android工程
準備工作: 請自行下載Gradle工具,本文使用的是gradle-2.10-all版本,你可以在後序提供的群中,下載此檔案; 綠色軟體,解壓即可; 在構建之前,需要約定專案的結構,並且需要一些必備的Gradle指令碼檔案 1:目錄及檔案的結構
AS離線開發和如何離線狀態下利用gradle來編譯android工程
首先,網上大部分的開發資料都是教我們如何去在android studio上怎麼離線開發。這個我也總結下流程。 1.點到preferences->build tools->gradle 下有
使用gradle打包android工程中出現的問題
1.依賴包,即使在build.gradle中聲明瞭依賴包;但是在gradle clean時候還是提示找不到library; 這樣就可以使用setting.gradle配置一下 include ':ViewPagerLibrary' include ':Volley' in
Jenkins+Gradle+pmd對Android工程原始碼進行靜態程式碼分析
轉載請注意出處:http://blog.csdn.net/hwhua1986/article/details/49278941 環境說明 Gradle 2.6. OS:windows server 2008 Jenkins 1.620 pmd 5.4.0 前提: Jen
從網上down下來的Android Studio 工程 開啟報sdk location not found錯誤的解決辦法
1.在根目錄下建立local.properties檔案。 2.在檔案中配置你的Android Sdk所在的目錄: sdk.dir = d:/AndroidSdk/sdk 注意路徑:不是\而是/
ArcGIS Android工程遷移到其他電腦不能打開的問題
好的 time runt 右上角 png iyu tle syn aliyun 問題描述:當我把已經做好的ArcGIS Android工程想在其他電腦運行時,總是會提示報錯。而報錯的地方,正是出現在下面這條語句上。 compile ‘com.esri.arcgis
Android工程改包名
右鍵 logs idm 選中 XML android mage and images 首先,在Androidmanifest.xml中修改package 如package="com.hb.zhsqzj" 然後,make project或者運行一次工程,生成R文件 接著在R文
Android工程 目錄講解
以下為Android demo的工程檔案 主要講解以下: src 檔案 -----------------------------放置Java檔案 gen檔案 -----------------------------裡面的R檔案有我
Android JS開啟原生應用
設定App通過網頁JS,喚醒開啟本地應用. 在AndroidManifest 中,在應用啟動頁配置下,新增android:exported="true",設定category 新增data 示例: 當配置應用的跳轉協議為: demo://?param1=引數1¶m2=引數二 當手機訪
android studio開啟無線除錯模式(無需刷機)
1、Android Studio 下載ADB Wifi外掛 File——Setting——Plugins下載ADB Wifi外掛,安裝成功後需重啟AS 2、設定除錯模式Run/Debug Configurations 3、確保手機開啟USB除錯功能 4、開啟無限除錯功能
Android工程架構設計:Base Library(基層MVP框架)基於EventBus
Base Library部分把App中Application,UI(activity,fragment)公用方法重新封裝成模板方法,並開放對子類的擴充套件。同時融入mvp設計思想,封裝成基於mvp的基層架構體系。 目錄 1,IApplication(介面): 2,BaseAp
Android工程架構設計:專案群架構設計
我們寫程式碼的時候,經常會把多個類相同的功能程式碼(方法)抽出來封裝成父類,各個子類繼承父類再做擴充套件。 隨著公司開發維護的專案越來越多,你會發現各個專案中有一些通用的可複用的程式碼或者模組,考慮到資源替換,工程複用等問題,需要把公共部分剝離出來。 公司名為sky_dreaming,目前公
Android分包方案multidex
Android分包方案multidex 1.對於功能越來越複雜的app的兩大問題 一:我們自己應用的方法數超過了65536 我們所說的方法數限制,這個方法數包括了jar包,框架,還有我們自己應用的程式碼,當我們應用的程式碼超過65536時,結果如下: 我們看到,顯示我們
Android Studio 開啟Annotation Processor斷點除錯
往gradle.properties檔案中新增如下兩行(本教程中是在~/.gradle/gradle.properties檔案中新增) org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=
Android Studio 開啟除錯 時 提示:could not connect to remote progress Aborting debug session
1. 在 AndroidMenifest.xml 新增: android:debuggable="true" 允許除錯。 <application android:debuggable="true" andr
使用eclipse CDT 除錯cocos2d-x 3.3 android 工程
現在的CDT技術以及Cocos2d-x已經發展到了一定程度,雖然使用CDT來除錯Native C++效率還不像VS中那麼高,但是為了使用C++開發android程式,為了實現跨平臺技術,能夠在android開發中實時除錯C++程式還是很有必要的。 第一次在eclipse下除錯C++,走了很多彎路,