2017-02-20 32 views

回答

1

爲什麼導致apk如此之大

Android PdfViewer依賴PdfiumAndroid,它是許多體系結構的本機庫(幾乎是16 MB)。 Apk必須包含所有這些庫,以便在市場上可用的所有設備上運行。幸運的是,Google Play允許我們上傳多個apks,例如每個架構一個。有關於自動將您的應用程序分成多個apks的好文章,可用here。最重要的部分是使用APK拆分改進多個APK創建和versionCode處理,但整篇文章值得一讀。你只需要在你的應用程序中這樣做,不需要分派PdfiumAndroid等等。

API:https://github.com/barteksc/AndroidPdfViewer

0

你必須生成不同的設備多個APK,這樣做可以減少APK的大小,達不到以前的10 MB。添加以下代碼的build.gradle(模塊:APP)

android{ 
    ..... 
    splits { 
     abi { 
      enable true 
      reset() 
      include 'x86_64', 'x86', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips' 
      universalApk false 
     } 




     } 
     ..... 


     } 
ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, mips: 4, 'x86': 5, 'x86_64': 6] 
import com.android.build.OutputFile 

// For each APK output variant, override versionCode with a combination of 
// ABI APK value * 1000 + defaultConfig.versionCode 
android.applicationVariants.all { variant -> 
    // assign different version code for each output 
    variant.outputs.each { output -> 
     output.versionCodeOverride = 
       project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) * 1000 + android.defaultConfig.versionCode 
    } 
} 

豔記視頻在這裏https://youtu.be/bP05Vpp49hs關於如何做到這一點詳細的解釋。

+0

它更像是一條評論 – Gahan