當我構建付費版本時,Android Studio(和Gradle)生成雙倍大小的apk文件?Android Studio(gradle)爲付費版本生成雙倍大小的apk文件
這是一個從Android Studio中和/或命令行相同的結果生成的apk:
gradle clean assembleRelease
它包括以下目錄額外:
assets/
main/
paid/
從而使得非常大。
我的build.gradle有付費版本的定義如下:
sourceSets {
paid {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/paid']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
在我的src /支付/ res目錄我只有以下額外的(自解壓APK):
40 ./res/drawable
8 ./res/drawable-hdpi
8 ./res/drawable-ldpi
8 ./res/drawable-mdpi
8 ./res/raw
8 ./res/raw-de
8 ./res/raw-sv
16 ./res/values
8 ./res/values-de
8 ./res/values-sv
120 ./res
120 .
而且我用的是以下幾點:
productFlavors {
free {
packageName "com.xyz.abc"
}
paid {
packageName "com.xyz.abcpro"
}
}
目錄大小以下(從APK解壓):
免費:
208 ./META-INF
8 ./org/apache/http/client
8 ./org/apache/http/entity/mime
8 ./org/apache/http/entity
24 ./org/apache/http
24 ./org/apache
24 ./org
888 ./res/drawable
584 ./res/drawable-hdpi
552 ./res/drawable-ldpi
560 ./res/drawable-mdpi
16 ./res/drawable-xhdpi
16 ./res/drawable-xxhdpi
488 ./res/layout
32 ./res/layout-land
8 ./res/layout-v10
16 ./res/layout-v17
8 ./res/layout-v7
8 ./res/layout-v8
64 ./res/menu
16 ./res/raw
16 ./res/raw-de
16 ./res/raw-sv
80 ./res/xml
3368 ./res
8448 .
付費:
8 ./assets/scripts
8 ./assets
1000 ./main/res/drawable
720 ./main/res/drawable-hdpi
584 ./main/res/drawable-ldpi
656 ./main/res/drawable-mdpi
16 ./main/res/drawable-xhdpi
24 ./main/res/drawable-xxhdpi
504 ./main/res/layout
40 ./main/res/layout-land
8 ./main/res/layout-v10
16 ./main/res/layout-v17
8 ./main/res/layout-v7
8 ./main/res/layout-v8
64 ./main/res/menu
16 ./main/res/raw
16 ./main/res/raw-de
16 ./main/res/raw-sv
152 ./main/res/values
72 ./main/res/values-de
72 ./main/res/values-sv
96 ./main/res/xml
4088 ./main/res
4104 ./main
368 ./META-INF
8 ./org/apache/http/client
8 ./org/apache/http/entity/mime
8 ./org/apache/http/entity
24 ./org/apache/http
24 ./org/apache
24 ./org
40 ./paid/res/drawable
8 ./paid/res/drawable-hdpi
8 ./paid/res/drawable-ldpi
8 ./paid/res/drawable-mdpi
8 ./paid/res/raw
8 ./paid/res/raw-de
8 ./paid/res/raw-sv
16 ./paid/res/values
8 ./paid/res/values-de
8 ./paid/res/values-sv
120 ./paid/res
120 ./paid
888 ./res/drawable
584 ./res/drawable-hdpi
552 ./res/drawable-ldpi
560 ./res/drawable-mdpi
16 ./res/drawable-xhdpi
16 ./res/drawable-xxhdpi
488 ./res/layout
32 ./res/layout-land
8 ./res/layout-v10
16 ./res/layout-v17
8 ./res/layout-v7
8 ./res/layout-v8
64 ./res/menu
16 ./res/raw
16 ./res/raw-de
16 ./res/raw-sv
80 ./res/xml
3368 ./res
14656 .
免費的apk大小:
-RW-R - R-- 1管理人員952930 1月6日10:01自由release.apk
付費apk大小:
-rw-r - r-- 1 admin staff 1880495 Jan 6 10:00 paid-release.apk
這是一個標準的Android Studio設置與主/ ,然後並行到主/以下目錄支付/:
.
./res
./res/drawable
./res/drawable/ic_launcher.png
./res/drawable/widget_icon_large.png
./res/drawable/widget_icon_small.png
./res/drawable-hdpi
./res/drawable-hdpi/ic_launcher.png
./res/drawable-ldpi
./res/drawable-ldpi/ic_launcher.png
./res/drawable-mdpi
./res/drawable-mdpi/ic_launcher.png
./res/raw
./res/raw/help.html
./res/raw-de
./res/raw-de/help.html
./res/raw-sv
./res/raw-sv/help.html
./res/values
./res/values/commons.xml
./res/values/strings.xml
./res/values-de
./res/values-de/strings.xml
./res/values-sv
./res/values-sv/strings.xml
工作室佈局:
UPDATE1:
當我添加了一個空目錄免費parallell付費,並改變了以下內容:
sourceSets {
free {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/free']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
paid {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/paid']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
現在都 apk具有相同和雙大小!?
更新2:
刪除sourceSets所有在一起,它的工作!
有趣的是,你有兩個目錄中的獨家資源(如應用程序標誌)? –
strings.xml我在這兩個目錄中,但只支付付費的特定更改。原始的,兩個目錄中的文件名相同但內容不同。在drawable中,我有相同的文件名稱作爲啓動器圖標,但具有不同的顏色設計。除此之外,所有這些都是默認的地方,沒有付費的重複。 – powder366
您已列出目錄大小,但實際上不屬於該帳戶的目錄中的大小差異是什麼? –