Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Android] Updated to latest Xamarin.Android.Support packages, release APK generated is now non-functioning #2495

Closed
Yelnik opened this issue Apr 18, 2018 · 12 comments
Labels
s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue.

Comments

@Yelnik
Copy link

Yelnik commented Apr 18, 2018

Description

Several Xamarin.Android.Support packages were version 26.1.0.1, I updated the packages to the current version 27.0.2, and the release APK generated is now 8 MB less than the debug build and crashes immediately on run

Debug build is 45156kb, release is 37217kb - This discrepancy was never the case before updating the Nuget packages

The project configurations are the same for the debug and release build

Steps to Reproduce

  1. Update Android support Nuget packages to latest
  2. Build in release and attempt to run

Expected Behavior

I expect the application to be runnable

Actual Behavior

The app crashes immediately

Basic Information

  • Version with issue: Xamarin.Android support libraries of version 27.0.2
  • Last known good version: 26.1.0.1
  • IDE: VS 2017 Professional
  • Platform Target Frameworks:
    • iOS:
    • Android: 8.2.0.16
    • UWP:
  • Android Support Library Version: 27.0.2
  • Nuget Packages:
  • Affected Devices: All

Screenshots

Reproduction Link

@PureWeen
Copy link
Contributor

Do you have a sample project where we could see the exception by chance? I have a few projects running at 27.0.2 and I'm not having this issue. I've seen a few people having issues around ProGuard and needing to modify the proguard config file. Do you have ProGuard enabled?

@Yelnik
Copy link
Author

Yelnik commented Apr 18, 2018

I don't even know where I would be able to see what the exception is since it's only in release that this happens

But it looks like if I disable ProGuard it does run properly, which is still strange, since ProGuard is enabled in the debug build

@PureWeen
Copy link
Contributor

With the debug build you might have linking setup differently (Full vs None) which causes some down stream differences.

I have an app with proguard and 27.0.2 running and it seems to be running fine (no crashes reported yet)

i left a comment here
#2457
with some suggestions of what to look into when you see crashes from proguard

@Yelnik
Copy link
Author

Yelnik commented Apr 18, 2018

I forgot to say the Linking is set to Sdk Assemblies Only in both debug and release

@PureWeen
Copy link
Contributor

I'd start by looking at log cat
Tools => Android => device log

when the app starts you'll most likely see some class that it can't find which you'll need to tell the linker to skip and/or setup an ignore in your proguard.cfg file

@Yelnik
Copy link
Author

Yelnik commented Apr 18, 2018

It's look like it's probably Didn't find class "android.support.v7.widget.FitWindowsFrameLayout

Edit: If I add Xamarin.Android.Support.v7.AppCompat to the Skip linking assemblies field it appears to work, but is this a good/safe solution?

@PureWeen
Copy link
Contributor

PureWeen commented Apr 18, 2018

So in your proguard.cfg file you can add

-keep class android.support.v7.widget.** { *; }
-dontwarn android.support.v7.widget.*

or be more specific with

-keep class android.support.v7.widget.FitWindowsFrameLayout { *; }
-dontwarn android.support.v7.widget.FitWindowsFrameLayout

and that should fix it for you

@Yelnik
Copy link
Author

Yelnik commented Apr 18, 2018

Actually, I don't have a CFG for ProGuard, I see there's one generated in \obj\Release\proguard, but editing that doesn't seem to have worked, and there's a lot more lines in it than I'd have expected

How do I go about adding one, or should I in this case?

@PureWeen
Copy link
Contributor

this talks about adding the proguard file

https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/proguard?tabs=vswin

it's pretty easy the only caveat is if you're on windows to be sure to read this part
https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/proguard?tabs=vswin#troubleshooting

@Yelnik
Copy link
Author

Yelnik commented Apr 18, 2018

My only concern is all of the configurations that were generated automatically, if I specify my own configuration, will these be lost? Or should I copy what's in the automatically generated one into my own?

@PureWeen
Copy link
Contributor

no they won't be lost
it'll use both

@samhouts samhouts added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Apr 18, 2018
@Yelnik
Copy link
Author

Yelnik commented Apr 18, 2018

Ok great, thanks a lot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue.
Projects
None yet
Development

No branches or pull requests

3 participants