Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link assemblies is crashing #3376

Closed
FANMixco opened this issue Jul 20, 2019 · 21 comments
Closed

Link assemblies is crashing #3376

FANMixco opened this issue Jul 20, 2019 · 21 comments
Assignees
Labels
need-info Issues that need more information from the author.

Comments

@FANMixco
Copy link

FANMixco commented Jul 20, 2019

Steps to Reproduce

  1. Add this property to any layout: android:fitsSystemWindows="true"

Example:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:layout_height="match_parent">
	
</android.support.design.widget.CoordinatorLayout>
  1. Choose Linker Behaviour: Link All Assemblies or Link SDK Assemblies
  2. Run the App in any emulator or physical device.

Expected Behavior

Run as expected.

Actual Behavior

Crashing on running.

Version Information

This issue is from the current stable to the latest preview.

Visual Studio Community 2019 for Mac
Version 8.2 (build 1090)
Installation UUID: d7f6c3e1-baa4-4504-81fc-0a87774bba8a
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.14.0.83 (d16-2 / f08d4e3e)

Package version: 600000311

Mono Framework MDK
Runtime:
Mono 6.0.0.311 (2019-02/494641b300c) (64-bit)
Package version: 600000311

NuGet
Version: 5.1.0.6013

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.12
2.1.11
2.1.9
2.1.8
2.1.7
2.1.6
2.1.2
2.1.1
2.0.5
2.0.0
1.1.2
1.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.701/Sdks
SDK Versions:
2.1.701
2.1.700
2.1.505
2.1.504
2.1.503
2.1.500
2.1.302
2.1.301
2.1.4
2.0.0
1.0.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/msbuild/Current/bin/Sdks

Xamarin.Profiler
Version: 1.6.11
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Xamarin.Android
Version: 9.4.0.51 (Visual Studio Community)
Commit: xamarin-android/d16-2/9fa7775
Android SDK: /Users/fanmixco/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 27.0.3

Build Information:
Mono: mono/mono@e6f5369c2d2
Java.Interop: xamarin/java.interop@d64ada5
LibZipSharp: grendello/LibZipSharp/d16-2@caa0c74
LibZip: nih-at/libzip@b95cf3f
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools@6f6c969

Microsoft Mobile OpenJDK
Java SDK: /Users/fanmixco/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android Device Manager
Version: 1.2.0.58
Hash: d03e3ea
Branch: remotes/origin/d16-2~1
Build date: 2019-07-10 20:46:18 UTC

Apple Developer Tools
Xcode 10.2.1 (14490.122)
Build 10E1001

Xamarin.Mac
Version: 5.14.0.110 (Visual Studio Community)
Hash: a8bcecce
Branch: d16-2
Build date: 2019-06-28 07:31:43-0400

Xamarin.iOS
Version: 12.14.0.110 (Visual Studio Community)
Hash: a8bcecce
Branch: d16-2
Build date: 2019-06-28 07:31:42-0400

Xamarin Designer
Version: 16.2.0.347
Hash: 9e8bf8f7c
Branch: remotes/origin/d16-2
Build date: 2019-07-03 00:59:58 UTC

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 802001090
Git revision: e7cb5ab98845ed937de94df83e2818cb4671aa13
Build date: 2019-07-12 16:16:40+00
Build branch: release-8.2
Xamarin extensions: 5a41faecc2127f5054df93eea5acfcc0884579b2

Operating System
Mac OS X 10.14.5
Darwin 18.6.0 Darwin Kernel Version 18.6.0
Thu Apr 25 23:16:27 PDT 2019
root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

Log File

Screen Shot 2019-07-20 at 07 32 45

@dellis1972 dellis1972 added the need-info Issues that need more information from the author. label Jul 23, 2019
@dellis1972
Copy link
Contributor

I am unable to repo locally on Xamarin.Android Version: 9.4.0.51 . Normally the Binary XML error means the resource processing failed for some reason...

The main difference it seems is my SDK Tooling has different versions

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 29.0.0

Can you try upgrading your tools to the latest versions and see if that helps.

If that does not help , can you provide a sample app which will demonstrate the issue.

@FANMixco
Copy link
Author

FANMixco commented Jul 23, 2019

I am unable to repo locally on Xamarin.Android Version: 9.4.0.51 . Normally the Binary XML error means the resource processing failed for some reason...

The main difference it seems is my SDK Tooling has different versions

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 29.0.0

Can you try upgrading your tools to the latest versions and see if that helps.

If that does not help , can you provide a sample app which will demonstrate the issue.

Is not the API 29 for Android Q that is still in Beta? Also, I posted both projects here:

#3263 (comment)

@FANMixco
Copy link
Author

I am unable to repo locally on Xamarin.Android Version: 9.4.0.51 . Normally the Binary XML error means the resource processing failed for some reason...

The main difference it seems is my SDK Tooling has different versions

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 29.0.0

Can you try upgrading your tools to the latest versions and see if that helps.

If that does not help , can you provide a sample app which will demonstrate the issue.

Also, I attached this one that is having issues too:

https://drive.google.com/open?id=1SkBx9IXv6ZSoi2PF6G4r02hjnL4MM0fq

@FANMixco
Copy link
Author

FANMixco commented Jul 24, 2019

I am unable to repo locally on Xamarin.Android Version: 9.4.0.51 . Normally the Binary XML error means the resource processing failed for some reason...

The main difference it seems is my SDK Tooling has different versions

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 29.0.0

Can you try upgrading your tools to the latest versions and see if that helps.

If that does not help , can you provide a sample app which will demonstrate the issue.

It works in Debug mode with the SDK 29, but not in Release.

@gugavaro gugavaro added this to To do in Mono SDKs Integration via automation Jul 24, 2019
@gugavaro gugavaro added this to the Under Consideration milestone Jul 24, 2019
@grendello grendello assigned radekdoulik and unassigned grendello Jul 24, 2019
@tipa
Copy link

tipa commented Jul 25, 2019

I think you need to add these lines into the ProGuard.cfg file:

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

The linker removes classes that are needed and apparently doesn't parse the axml to see that they are in fact needed

@FANMixco
Copy link
Author

I think you need to add these lines into the ProGuard.cfg file:

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

The linker removes classes that are needed and apparently doesn't parse the axml to see that they are in fact needed

As far as I remember ProGuard is legacy, right? I'm using R8 for the projects. Do you something about it? Also, I'm using only XMLs, should I use AXMLs? Thanks for the clarifications.

@tipa
Copy link

tipa commented Jul 26, 2019

The ProGuard file is still used, even when using R8.
I think it makes no function difference if you use xml instead of axml, but axml might have better Visual Studio support (intellisense etc).

Just my guesses though, I am not a Xamarin team member

@JonDouglas
Copy link
Contributor

RE: .axml vs .xml. In 16.2 and 8.2 (Visual Studio and Visual Studio for Mac), these have equivalent support for intellisense and layout editing tooling. Prior to that, Android layouts were detected via the .axml extension.

@FANMixco
Copy link
Author

I think you need to add these lines into the ProGuard.cfg file:

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

The linker removes classes that are needed and apparently doesn't parse the axml to see that they are in fact needed

This one didn't work.

@jonathanpeppers
Copy link
Member

@FANMixco can you post an updated project where you added these rules? It seems like that should fix your issue. Thanks!

Just a couple notes:

  • I think this issue is related to r8 instead of the Mono linker? Is that correct?
  • r8 is basically a new version of ProGuard if you want to think of it that way.

@FANMixco
Copy link
Author

FANMixco commented Aug 5, 2019

It didn't work as I said.

Screen Shot 2019-08-05 at 18 00 25

Screen Shot 2019-08-05 at 18 00 33

New project:

https://drive.google.com/open?id=1_f28lo0NPT2OZNCTZROnPpCiPssSetgF

@jonathanpeppers
Copy link
Member

Can you post the full diagnostic build log here?

This screenshot is a linker error and completely different than a crash at runtime. I think we might be confusing two different problems here.

@FANMixco
Copy link
Author

FANMixco commented Aug 5, 2019

Can you post the full diagnostic build log here?

This screenshot is a linker error and completely different than a crash at runtime. I think we might be confusing two different problems here.

Yes, I know and it started to happen in the latest edition of VS for Mac. I cannot reproduce the previous error since I cannot do it anymore.

@jonathanpeppers
Copy link
Member

Could you have just modified your $(TargetFrameworkVersion)?

If so, we found/fixed an issue that might be the problem here: #3405

Is the runtime error still happening?

@FANMixco
Copy link
Author

FANMixco commented Aug 5, 2019

Could you have just modified your $(TargetFrameworkVersion)?

If so, we found/fixed an issue that might be the problem here: #3405

Is the runtime error still happening?

I haven't changed anything. I only did this:

Screen Shot 2019-08-05 at 18 52 25

Screen Shot 2019-08-05 at 18 52 29

If it was automatically changed by VS for Mac, then that's the answer, but I didn't change anything and the bug that I showed happened almost 2 weeks ago, this is the current version that I have:

Visual Studio Community 2019 for Mac
Version 8.2.1 (build 19)
Installation UUID: abf63767-43c1-49b0-837d-d3e3bc117881
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 5.14.0.85 (d16-2-fix-mac-updates / 86973979)

	Package version: 600000311

Mono Framework MDK
Runtime:
	Mono 6.0.0.311 (2019-02/494641b300c) (64-bit)
	Package version: 600000311

NuGet
Version: 5.1.0.6013

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	2.1.12
	2.1.11
	2.1.9
	2.1.8
	2.1.7
	2.1.6
	2.1.2
	2.1.1
	2.0.5
	2.0.0
	1.1.2
	1.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.701/Sdks
SDK Versions:
	2.1.701
	2.1.700
	2.1.505
	2.1.504
	2.1.503
	2.1.500
	2.1.302
	2.1.301
	2.1.4
	2.0.0
	1.0.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/msbuild/Current/bin/Sdks

Xamarin.Profiler
Version: 1.6.11
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 10.3 (14492.2)
Build 10G8

Xamarin.Mac
Version: 5.14.0.110 (Visual Studio Community)
Hash: a8bcecce
Branch: d16-2
Build date: 2019-06-28 07:31:43-0400

Xamarin.iOS
Version: 12.14.0.110 (Visual Studio Community)
Hash: a8bcecce
Branch: d16-2
Build date: 2019-06-28 07:31:42-0400

Xamarin Designer
Version: 16.2.0.375
Hash: 357d38ef4
Branch: remotes/origin/d16-2
Build date: 2019-07-26 14:44:54 UTC

Xamarin.Android
Version: 9.4.0.51 (Visual Studio Community)
Commit: xamarin-android/d16-2/9fa7775
Android SDK: /Users/fanmixco/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 27.0.3

Build Information: 
Mono: mono/mono/2019-02@e6f5369c2d2
Java.Interop: xamarin/java.interop/d16-2@d64ada5
LibZipSharp: grendello/LibZipSharp/d16-2@caa0c74
LibZip: nih-at/libzip/rel-1-5-1@b95cf3f
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-2@6f6c969

Microsoft Mobile OpenJDK
Java SDK: /Users/fanmixco/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android Device Manager
Version: 1.2.0.58
Hash: d03e3ea
Branch: remotes/origin/d16-2~1
Build date: 2019-07-16 17:37:14 UTC

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 802010019
Git revision: c7aee29ba7d2a827dbfe4901e4ad7249ce7e5bc7
Build date: 2019-07-29 20:22:23+00
Build branch: release-8.2
Xamarin extensions: c990de17e8456ead7fce80aff9dab01df769b2fd

Operating System
Mac OS X 10.14.5
Darwin 18.6.0 Darwin Kernel Version 18.6.0
    Thu Apr 25 23:16:27 PDT 2019
    root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

In this project it happens:

https://drive.google.com/open?id=1ka2iNlzrD57aD_3K8Yt7hzfyPlCQNOj0

I haven't done any change and the other one I cannot reproduce it since it's crashing since this release.

@jonathanpeppers
Copy link
Member

So the TheMayanRoute project, I got a new error after adding the proguard rules:

java.lang.NoSuchFieldException: No field mCursorDrawable in class Landroid/widget/TextView; (declaration of 'android.widget.TextView' appears in /system/framework/framework.jar!classes2.dex)

So it does seem like the proguard rules fix something, just on to the next issue.

Your Xamarin-MaterialSearchBar library looks like it is using reflection against an Android field that doesn't exist:

https://github.com/FANMixco/Xamarin-SearchBar/blob/c30762a1d3a8c40242a5af022b996d0989206dca/tk.supernovaic.MaterialSearchBar/MaterialSearchBar.cs#L374-L382

Is this other project you linked to the same issue? or something else?

@FANMixco
Copy link
Author

FANMixco commented Aug 5, 2019

So the TheMayanRoute project, I got a new error after adding the proguard rules:

java.lang.NoSuchFieldException: No field mCursorDrawable in class Landroid/widget/TextView; (declaration of 'android.widget.TextView' appears in /system/framework/framework.jar!classes2.dex)

So it does seem like the proguard rules fix something, just on to the next issue.

Your Xamarin-MaterialSearchBar library looks like it is using reflection against an Android field that doesn't exist:

https://github.com/FANMixco/Xamarin-SearchBar/blob/c30762a1d3a8c40242a5af022b996d0989206dca/tk.supernovaic.MaterialSearchBar/MaterialSearchBar.cs#L374-L382

Is this other project you linked to the same issue? or something else?

Yes, this is the other project and it has other issues in certain cases, but I have never seen that one.

@jonathanpeppers
Copy link
Member

I don't see this mCursorDrawable field in the latest Android: https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java

So your code here is probably breaking on newer devices; I have a Pixel 3 XL running Android 9.0 Pie.

@FANMixco
Copy link
Author

FANMixco commented Aug 5, 2019

I don't see this mCursorDrawable field in the latest Android: https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java

So your code here is probably breaking on newer devices; I have a Pixel 3 XL running Android 9.0 Pie.

I have all my Apps running in Android Pie too with a Xiaomi A2 Lite and I don't have any issue regarding this (no compression and linking).

Screenshot_20190805-214342
Screenshot_20190805-214353
Screenshot_20190805-214410

@jonathanpeppers
Copy link
Member

Ah you are logging this and going on: https://github.com/FANMixco/Xamarin-SearchBar/blob/c30762a1d3a8c40242a5af022b996d0989206dca/tk.supernovaic.MaterialSearchBar/MaterialSearchBar.cs#L384-L391

The actual error is:

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.internal.BaselineLayout" on path

I adjusted the rules to:

# This one used to be:
# -keep class android.support.design.widget.** { *; }
-keep class android.support.design.** { *; }
-keep class android.support.v7.widget.** { *; }

Then it worked.

@jonathanpeppers
Copy link
Member

@FANMixco I think we resolved what was going on here, right? The issue was proguard/r8 removing android.support.design.internal.BaselineLayout?

Let me know and we can reopen if needed, thanks!

@xamarin xamarin locked as resolved and limited conversation to collaborators Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need-info Issues that need more information from the author.
Projects
None yet
Development

No branches or pull requests

8 participants