Closed leonluc-dev closed 5 years ago
So, we do include the proguard.txt file that is in the original .aar:
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Preference objects are inflated via reflection
-keep public class android.support.v7.preference.Preference {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class * extends android.support.v7.preference.Preference {
public <init>(android.content.Context, android.util.AttributeSet);
}
This doesn't look obviously the same as your rule set. Would you be able to share a diagnostic build log (or better yet a binlog) of your project? I'd like to see / ensure that the .aar file we do ship is being considered in the proguard call.
@Redth While I'm still waiting for approval to publish the binlog. I have noticed something interesting about the nuget packages. I have my project target set to <TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
(monoandroid90
), and it seems that most of the packages that require proguard rules do not include them for that particular platform (while the lib folders do contain the dlls).
Directory of <redacted>\.nuget\packages\xamarin.android.support.v7.preference\28.0.0\proguard
18 Dec 2018 11:38 <DIR> .
18 Dec 2018 11:38 <DIR> ..
18 Dec 2018 11:38 <DIR> monoandroid71
18 Dec 2018 11:38 <DIR> monoandroid80
18 Dec 2018 11:38 <DIR> monoandroid81
0 File(s) 0 bytes
5 Dir(s) 130.333.097.984 bytes free
Directory of <redacted>\.nuget\packages\xamarin.android.support.v7.preference\28.0.0\lib
18 Dec 2018 11:38 <DIR> .
18 Dec 2018 11:38 <DIR> ..
18 Dec 2018 11:38 <DIR> monoandroid60
18 Dec 2018 11:38 <DIR> monoandroid70
18 Dec 2018 11:38 <DIR> monoandroid71
18 Dec 2018 11:38 <DIR> monoandroid80
18 Dec 2018 11:38 <DIR> monoandroid81
18 Dec 2018 11:38 <DIR> monoandroid90
0 File(s) 0 bytes
8 Dir(s) 130.333.208.576 bytes free
This is not only the case for the preference library but for all xamarin.android.support
packages.
Could this have anything to do with the cause of this issue?
I have attached the binlog for a recent build. Binlog-2019-01-14.zip
Any updates on this? The issue seems to indeed be that the proguard configs are missing for monoandroid90.
Take for example the latest version of Xamarin.Android.Support.v7.RecyclerView: in the nupkg, build/monoandroid81/Xamarin.Android.Support.v7.RecyclerView.targets contains this:
<ItemGroup>
<ProguardConfiguration Include="$(MSBuildThisFileDirectory)..\..\proguard\monoandroid81\proguard.txt" />
</ItemGroup>
while build/monoandroid90/Xamarin.Android.Support.v7.RecyclerView.targets does not:
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
And like @gameleon-dev noticed, under the proguard/ folder there's no subfolder for monoandroid90.
I created a minimal project (attached) which just creates a RecyclerView and specifies the layout manager in xml. When building with 8.1 everything works, but after switching to 9.0 the app crashes on launch, as LinearLayoutManager is removed by Proguard.
I built the fat Nuget packages from current master branch locally and they contain the correct Proguard config files even for monoandroid90.
Is there going to be a public 28.0.0.2 release? It seems that just releasing the current version could fix this issue. The missing proguard config is currently preventing us from upgrading to Support Library 28 or Google Play Services 71. Having a working release before the AndroidX migration would be very helpful.
This is fixed in 28.0.0.3
I built the fat Nuget packages from current master branch locally and they contain the correct Proguard config files even for monoandroid90.
Is there going to be a public 28.0.0.2 release? It seems that just releasing the current version could fix this issue. The missing proguard config is currently preventing us from upgrading to Support Library 28 or Google Play Services 71. Having a working release before the AndroidX migration would be very helpful.
@luryus, most likely you will need custom proguard rules anyway due to LinkerSafe attribute for monoadroid90, see https://github.com/xamarin/AndroidSupportComponents/issues/219
@yaliashkevich We actually ran into issues with java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FitWindowsFrameLayout"
, but I think the reason for that is not related to linking. We fixed it with the workaround here: https://github.com/xamarin/xamarin-android/issues/3636
Basically, Xamarin.Android does not use the proguard configuration generated by AAPT, and classes referenced via XML are stripped out by proguard or something like that.
I don't know if this is actually related to the linker changes. It could be, but our app works fine with linker enabled and the proguard configuration generated by the workaround.
@yaliashkevich FWIK there should be 28.0.0.3 released.
For example
https://www.nuget.org/packages/Xamarin.Android.Support.Design/
https://www.nuget.org/packages/Xamarin.Android.Support.Design/28.0.0.3
@luryus, LinkerSafe attribute for monodroid90 is exact reason. Isn’t it ridiculous to have it on a library so tied with reflection and inflation from xml.
Thank you for pointing to https://github.com/xamarin/xamarin-android/issues/3636, that gonna save me from running million build-run-catch exception-update proguard rules iterations made by hand.
Xamarin.Android Version (eg: 6.0):
9.1.4.2
Operating System & Version (eg: Mac OSX 10.11):
Windows 10 (1809)
Support Libraries Version (eg: 23.3.0):
28.0.0
Describe your Issue:
This is a followup to issue #96 After updating to version 28.0.0 a few new issues started popping up.
Among others
android.support.v7.widget.FitWindowsFrameLayout
andandroid.support.v7.preference.PreferenceCategory
are giving issues during inflation. I've adjusted my proguard configuration file to explicitly include (the packages of) these classes, but these rules are supposed to be included with the support library itself (at least they are in Android Studio).Steps to Reproduce (with link to sample solution if possible):
Build a project with Proguard enabled and use the (for example) PreferenceCategory class in a xml file. Then inflate said xml file in code.
Temporary workaround
Add the following to the ProGuard configuration file:
Example stack trace