簡體   English   中英

適用於MDPI,HDPI,XHDPI和XXHDPI的不同APK

[英]Different APK for MDPI, HDPI, XHDPI and XXHDPI

在我的應用中,我的圖像中有太多圖像,因此現在apk的大小變得很大(70 MB)。 是否可以為MDPI,HDPI,XHDPI和XXHDPI手機上傳不同的apk文件。 如果HDPI電話用戶正在下載我的應用程序,那么Google會播放消息,他應該只獲取我應用程序的HDPI版本。 (與MDPI / XHDPI / XXHDPI相同。)

編輯:

我已經成功創建了4個不同的APK文件(用於mdpi,hdpi,xhdpi,xxhdpi)。 我只添加了以下代碼以顯示所有hdpi設備:

<compatible-screens>
    <screen
        android:screenDensity="hdpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="xlarge" />
</compatible-screens>

和我為xhdpi和xxhdpi做的一樣。

現在的問題是,我正在嘗試在Google Play上上傳我的4個(相同應用程序的)apk文件。 但是我找不到能使我上載同一應用4個apk的功能。 我只找到了可以上傳一個apk文件的選項。

請指導我如何在Google Play上上傳4個不同的同一個應用程序apk(每個文件分別用於mdpi,hdpi,xhdpi,xxhdpi)。

是的,您可以構建多個APK以減小下載大小(

在您的情況下:

android {
  ...
  splits {

    // Configures multiple APKs based on screen density.
    density {

      // Configures multiple APKs based on screen density.
      enable true

      reset()  // Clears the default list from all densities to no densities.
      include "mdpi", "hdpi", "xhdpi", "xxhdpi" // Specifies the two densities we want to generate APKs for.
    }
  }
}

或者您可以排除不需要的密度:

android {
  ...
  splits {
    density {    
      enable true
      exclude "ldpi", "xxxhdpi"
    }
  }
}

然后,當您執行assembleRelease ,您將獲得一個密度的APK +一個通用的APK。 如果您不希望通用APK,請指定universalApk false

同樣,如果您有本機庫,則還可以為每個ABI創建一個不同的APK。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM