標籤:筆記 指定 pat def crash android開發 技術 地區 tap
接上篇《android開發藝術探索》讀書筆記(十二)--Bitmap的載入和Cache
No1:
使用CrashHandler來擷取應用的crash資訊
No2:
在Android中單個dex檔案所能夠包含的最大方法數為65536,這包含Android FrameWork、依賴的jar包以及應用本身的代碼中的所有方法。
No3:
使用multidex來解決方案數越界
apply plugin: ‘com.android.application‘android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "com.ryg.multidextest" minSdkVersion 8 targetSdkVersion 22 versionCode 1 versionName "1.0" // enable multidex support multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘ } }}afterEvaluate { println "afterEvaluate" tasks.matching { it.name.startsWith(‘dex‘) }.each { dx -> def listFile = project.rootDir.absolutePath + ‘/app/maindexlist.txt‘ println "root dir:" + project.rootDir.absolutePath println "dex task found: " + dx.name if (dx.additionalParameters == null) { dx.additionalParameters = [] } dx.additionalParameters += ‘--multi-dex‘ dx.additionalParameters += ‘--main-dex-list=‘ + listFile dx.additionalParameters += ‘--minimal-main-dex‘ }}dependencies { compile fileTree(dir: ‘libs‘, include: [‘*.jar‘]) compile ‘com.android.support:appcompat-v7:22.1.1‘ compile ‘com.android.support:multidex:1.0.0‘}
afterEvaluate地區是為了指定dex檔案中包含哪些類,類名寫在maindexlist.txt中
注意:multidex的jar包中的9個類必須也要打包到主dex中
代碼支援
public class TestApplication extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); }}
Multidex方法雖然很好地解決了方法數越界這個問題,但也會導致應用啟動速度會降低,是因為應用啟動時會載入額外的dex檔案。
No4:
Android動態載入技術(外掛程式化技術)
No5:
反編譯
《android開發藝術探索》讀書筆記(十三)--綜合技術