《android開發藝術探索》讀書筆記(十三)--綜合技術

來源:互聯網
上載者:User

標籤:筆記   指定   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開發藝術探索》讀書筆記(十三)--綜合技術

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.