gpt4 book ai didi

c# - 存档的 APK 文件非常大 - Xamarin.Android

转载 作者:搜寻专家 更新时间:2023-11-01 09:33:37 34 4
gpt4 key购买 nike

归档我的应用后,我的 apk 大小为 71.82MB(估计的应用商店大小)。我的应用程序中也没有很多图像。

此外,我将链接器设置为不链接,这是唯一适合我的选项。它对用户来说太大了。当我将链接器设置为仅链接 SDK 程序集并链接所有程序集时,我收到 java exit 1 代码错误。

我可以遵循一些步骤来减小我的 apk 的大小吗?

**应用崩溃的地方**

传递给工具的环境变量:

    PROGUARD_HOME=/Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/proguard
/usr/bin/java -jar /Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/proguard/lib/proguard.jar -include /Users/emmnock/AndroidStudioProjects/android-sdk-macosx//tools/proguard/proguard-android.txt -include obj/Release/proguard/proguard_xamarin.cfg -include obj/Release/proguard/proguard_project_references.cfg -include obj/Release/proguard/proguard_project_primary.cfg -include proguard.cfg -include obj/Release/XbdMerge/proguard/00d975c90.txt -include obj/Release/XbdMerge/proguard/0757626b0.txt -include obj/Release/XbdMerge/proguard/1db418320.txt -include obj/Release/XbdMerge/proguard/1f4fd9cc0.txt -include obj/Release/XbdMerge/proguard/211c61910.txt -include obj/Release/XbdMerge/proguard/2f4d086a0.txt -include obj/Release/XbdMerge/proguard/581878c90.txt -include obj/Release/XbdMerge/proguard/67b1d0a90.txt -include obj/Release/XbdMerge/proguard/8f1de9cb0.txt -include obj/Release/XbdMerge/proguard/a35ed7280.txt -include obj/Release/XbdMerge/proguard/acdd43380.txt -include obj/Release/XbdMerge/proguard/b76e0d310.txt -include obj/Release/XbdMerge/proguard/c756521f0.txt -include obj/Release/XbdMerge/proguard/d87effcf0.txt -include obj/Release/XbdMerge/proguard/d99a9fda0.txt -include obj/Release/XbdMerge/proguard/d9f2c52f0.txt -include obj/Release/XbdMerge/proguard/dc663e480.txt -include obj/Release/XbdMerge/proguard/e5bf18810.txt -include obj/Release/XbdMerge/proguard/e843ef2a0.txt -include obj/Release/XbdMerge/proguard/fb4df8d50.txt "-injars 'obj/Release/proguard/__proguard_input__.jar':'/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v7.1/mono.android.jar':'/Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/android-support-multidex.jar':'obj/Release/__library_projects__/Bolts.AppLinks/library_project_imports/bin/classes.jar':'obj/Release/__library_projects__/Bolts.Tasks/library_project_imports/bolts-tasks.jar':'obj/Release/__library_projects__/EasySplashScreen/library_project_imports/bin/classes.jar':'obj/Release/__library_projects__/ExoPlayer/library_project_imports/bin/classes.jar':'obj/Release/__library_projects__/FormsViewGroup/library_project_imports/formsviewgroup.jar':'obj/Release/__library_projects__/Glide/library_project_imports/glide-3.8.0.jar':'obj/Release/__library_projects__/Refractored.Controls.CircleImageView/library_project_imports/bin/classes.jar':'obj/Release/__library_projects__/Square.OkHttp/library_project_imports/okhttp.jar':'obj/Release/__library_projects__/Square.OkIO/library_project_imports/okio.jar':'obj/Release/__library_projects__/Square.Picasso/library_project_imports/picasso-2.5.2.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Animated.Vector.Drawable/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Compat/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Core.UI/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Core.Utils/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.CustomTabs/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Design/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Fragment/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Media.Compat/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Transition/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.Vector.Drawable/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.v4/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.v7.AppCompat/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.v7.CardView/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.v7.MediaRouter/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.v7.Palette/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Android.Support.v7.RecyclerView/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Facebook/library_project_imports/bin/classes.jar':'obj/Release/__library_projects__/Xamarin.Facebook.AudienceNetwork/library_project_imports/bin/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Analytics/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Analytics.Impl/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Auth/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Common/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Database/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Database.Connection/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Iid/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Storage/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.Firebase.Storage.Common/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.GooglePlayServices.Ads/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.GooglePlayServices.Ads.Lite/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.GooglePlayServices.Base/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.GooglePlayServices.Basement/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.GooglePlayServices.Clearcut/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.GooglePlayServices.Gass/library_project_imports/classes.jar':'obj/Release/__library_projects__/Xamarin.GooglePlayServices.Tasks/library_project_imports/classes.jar'" "-libraryjars '/Users/emmnock/AndroidStudioProjects/android-sdk-macosx/platforms/android-25/android.jar'" -outjars "obj/Release/proguard/__proguard_output__.jar" -optimizations !code/allocation/variable
proguard.ParseException: Unknown option '' in line 1 of file 'proguard.cfg',
included from argument number 10
at proguard.ConfigurationParser.parse(Unknown Source)
at proguard.ProGuard.main(Unknown Source)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1922,3): error MSB6006: "java" exited with code 1.
Done executing task "Proguard" -- FAILED.
Done building target "_CompileToDalvikWithDx" in project "FindMeApp.Droid.csproj" -- FAILED.

Done building project "FindMeApp.Droid.csproj" -- FAILED.

最佳答案

让我们谈谈这个。有几件事最终会使您的应用程序变得非常大。

<强>1。单链接器

根据您的链接器行为集,如果不采用更积极的链接行为,您可能会冒相当大的空间风险。也就是说,如果您将链接器行为设置为 None,则表示“即使未使用,也请将所有内容包含在我的应用程序中”。这会添加相当多的多余类/构造函数/方法/等,从而使程序集文件膨胀。这是一个托管链接器,这意味着它将仅链接您的托管代码 (C#)

查看我的博客:

http://www.jon-douglas.com/2017/04/13/linker-bitdiffer/

<强>2。 CPU架构

您可能在 APK 中包含了超出您实际需要的过多架构。每增加一个 ABI,您的应用程序就会变得相当臃肿。

https://developer.xamarin.com/guides/android/application_fundamentals/cpu_architectures/#How_to_Specify_Supported_Architectures

也可以在这里查看我的回答:Which Xamarin ABIs should we support

<强>3。资源/原始文件

您的应用程序中包含大量资源和原始文件。在开发应用程序时,您可能会引入一些资源。但是,您实际上可能没有注意其中一些资源有多大。找出 APK 膨胀的主要原因的一个技巧是使用 WinDirStat( https://windirstat.info/ ) 或 Disk Inventory X( http://www.derlien.com/ ) 之类的工具来调查为什么您的 .apk 如此之大。

<强>4。混淆器

最后,Proguard 可用作通过删除未使用的类、字段、方法和属性来缩小 APK 的一种方法。将 Proguard 视为一个 native 链接器,它将优化您的字节码并删除未使用的代码指令。

在此处查看我为此编写的文档:

http://www.jon-douglas.com/2016/11/22/xamarin-android-proguard/

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/proguard/#Overview

回复:为什么 Proguard 失败了

你可以在这里看到我的帖子:

Xamarin proguard.ParseException: Unknown option '' in line 1 of file 'Properties/proguard.cfg'

关于c# - 存档的 APK 文件非常大 - Xamarin.Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45147194/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com