dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.92k stars 526 forks source link

Failed resolution of: Landroid/support/v7/appcompat/R$<something> #2333

Closed regisramillien closed 5 years ago

regisramillien commented 5 years ago

Steps to Reproduce

  1. Cannot reproduce systematically. Happened to me when adding images on resources/drawable.
  2. Build and deploy
  3. When it crash, delete bin and obj folders

Expected Behavior

Do not crash.

The bug exists still at least april 2016.

Actual Behavior

The same issue is described and resolved here using response from dot_ly (delete bin and obj folders):

https://forums.xamarin.com/discussion/64109/failed-resolution-of-landroid-support-v7-appcompat-r-styleable-code-works-for-others-not-my-mac

Version Information

Microsoft Visual Studio Community 2017 Version 15.8.7 VisualStudio.15.Release/15.8.7+28010.2046 Microsoft .NET Framework Version 4.7.03062

Version installée : Community

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.1.49 (remotes/origin/d15-8@ee674f3) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Extension ResourcePackage 1.0 Informations détaillées sur l'extension Visual Studio ResourcePackage

Extension ResourcePackage 1.0 Informations détaillées sur l'extension Visual Studio ResourcePackage

Gestionnaire de package NuGet 4.6.0 Gestionnaire de package NuGet dans Visual Studio. Pour plus d'informations sur NuGet, consultez la page http://docs.nuget.org/.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Mono Debugging for Visual Studio 4.11.11-pre (8fb558f) Support for debugging Mono processes with Visual Studio.

Outils C# 2.9.0-beta8-63208-01 Composants C# utilisés dans l'IDE. En fonction de votre type de projet et de vos paramètres, une autre version du compilateur peut être utilisée.

Outils Visual Basic 2.9.0-beta8-63208-01 Composants Visual Basic utilisés dans l'IDE. En fonction de votre type de projet et de vos paramètres, une autre version du compilateur peut être utilisée.

Package hôte de l'adaptateur de débogage de Visual Studio Code 1.0 Couche d'interopérabilité pour l'hébergement d'adaptateurs de débogage Visual Studio Code dans Visual Studio

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

Visual F# Tools 10.2 pour F# 4.5 15.8.0.0. Commit Hash: 55a3dc3231c95c77f81ee53f7d29152029da7408. Microsoft Visual F# Tools 10.2 pour F# 4.5

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

Xamarin 4.11.0.776 (d15-8@1ae9b59d7) Extension Visual Studio permettant de développer pour Xamarin.iOS et Xamarin.Android.

Xamarin Designer 4.15.9 (d000f568b) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 1.1.116 (9619170) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 9.0.0.19 (HEAD/a8a3b0ec7) Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 12.0.0.15 (84552a4) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Log File

No logs, please see url above to see log files.

jonathanpeppers commented 5 years ago

@regisramillien can you paste the exact error message you're getting? A MSBuild diagnostic log would also help.

We fixed a few issues related to this, which is now available in the VS 15.9 preview. Could you try it and see if the problem goes away? You can install it side-by-side stable.

sdebruyn commented 5 years ago

Same issue here. Happens sometimes and you have to clean, uninstall app on device before it works again.

=== Visual Studio Enterprise 2017 for Mac ===

Version 7.6.10 (build 27)
Installation UUID: e1324239-09f8-4ef0-841d-818a176fdfbd
Runtime:
    Mono 5.12.0.309 (2018-02/39d89a335c8) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

    Package version: 512000309

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    2.1.2
    2.1.1
    2.1.0
    2.0.7
    2.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK Versions:
    2.1.302
    2.1.301
    2.1.300
    2.1.200
    2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

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

=== Apple Developer Tools ===

Xcode 10.1 (14460.46)
Build 10B61

=== Xamarin.Mac ===

Version: 5.0.0.0 (Visual Studio Enterprise)
Hash: b40230c0
Branch: 
Build date: 2018-09-27 11:41:37-0400

=== Xamarin.iOS ===

Version: 12.0.0.15 (Visual Studio Enterprise)
Hash: 84552a46
Branch: xcode10
Build date: 2018-09-17 21:54:33-0400

=== Xamarin.Android ===

Version: 9.0.0.20 (Visual Studio Enterprise)
Android SDK: /Users/sam/Library/Android/sdk
    Supported Android versions:
        5.0 (API level 21)
        6.0 (API level 23)
        7.0 (API level 24)
        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: 28.0.1
SDK Build Tools Version: 28.0.3

Java SDK: /usr
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== 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: 706100027
Git revision: 94dbd4d35daaa5a2ff6a51c3fd5cbb2308bd83ea
Build date: 2018-10-18 16:34:31+00
Build branch: release-7.6
Xamarin extensions: 3a9afc960ba73e5862829e8a0cd9369bcca43d70

=== Operating System ===

Mac OS X 10.14.0
Darwin 18.0.0 Darwin Kernel Version 18.0.0
    Wed Aug 22 20:13:40 PDT 2018
    root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

Android Signature Tool 2.1.2
Gist Ide Information 1.1.0
MSBuild Editor 2.0.4
NuGet Package Explorer 0.2
NuGet Package Management Extensions 0.13
xUnit.NET 2 testing framework support 0.7.5

Will post all info I can get next time it happens.

sdebruyn commented 5 years ago

It's happening again...

buildlog.txt image

Outer exception stack trace:


  --- End of managed Java.Lang.NoClassDefFoundError stack trace ---
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/appcompat/R$drawable;
    at android.support.v7.widget.AppCompatDrawableManager.<clinit>(AppCompatDrawableManager.java:107)
    at android.support.v7.widget.AppCompatDrawableManager.get(AppCompatDrawableManager.java:84)
    at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:85)
    at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:128)
    at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:149)
    at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:29)
    at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:54)
    at android.support.v7.app.AppCompatDelegateImplV23.<init>(AppCompatDelegateImplV23.java:31)
    at android.support.v7.app.AppCompatDelegateImplN.<init>(AppCompatDelegateImplN.java:31)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:198)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
    at mvvmcross.droid.support.v7.appcompat.MvxSplashScreenAppCompatActivity.n_onCreate(Native Method)
    at mvvmcross.droid.support.v7.appcompat.MvxSplashScreenAppCompatActivity.onCreate(MvxSplashScreenAppCompatActivity.java:31)
    at android.app.Activity.performCreate(Activity.java:6679)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.appcompat.R$drawable" on path: DexPathList[[zip file "/data/app/my.package.name-1/base.apk"],nativeLibraryDirectories=[/data/app/my.package.name-1/lib/x86_64, /data/app/my.package.name-1/base.apk!/lib/x86_64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 27 more

Inner exception stack trace:


  --- End of managed Java.Lang.ClassNotFoundException stack trace ---
java.lang.ClassNotFoundException: Didn't find class "android.support.v7.appcompat.R$drawable" on path: DexPathList[[zip file "/data/app/my.package.name-1/base.apk"],nativeLibraryDirectories=[/data/app/my.package.name-1/lib/x86_64, /data/app/my.package.name-1/base.apk!/lib/x86_64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.support.v7.widget.AppCompatDrawableManager.<clinit>(AppCompatDrawableManager.java:107)
    at android.support.v7.widget.AppCompatDrawableManager.get(AppCompatDrawableManager.java:84)
    at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:85)
    at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:128)
    at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:149)
    at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:29)
    at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:54)
    at android.support.v7.app.AppCompatDelegateImplV23.<init>(AppCompatDelegateImplV23.java:31)
    at android.support.v7.app.AppCompatDelegateImplN.<init>(AppCompatDelegateImplN.java:31)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:198)
    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
    at mvvmcross.droid.support.v7.appcompat.MvxSplashScreenAppCompatActivity.n_onCreate(Native Method)
    at mvvmcross.droid.support.v7.appcompat.MvxSplashScreenAppCompatActivity.onCreate(MvxSplashScreenAppCompatActivity.java:31)
    at android.app.Activity.performCreate(Activity.java:6679)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Message:

Didn't find class "android.support.v7.appcompat.R$drawable" on path: DexPathList[[zip file "/data/app/my.package.name-1/base.apk"],nativeLibraryDirectories=[/data/app/my.package.name-1/lib/x86_64, /data/app/my.package.name-1/base.apk!/lib/x86_64, /system/lib64, /vendor/lib64]]

Call stack:

System.Diagnostics.Debugger.Mono_UnhandledException_internal() in 
System.Diagnostics.Debugger.Mono_UnhandledException(Java.Lang.NoClassDefFoundError ex) in 
object.11( Parameters) in 
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in 
Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) in 
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, My.Namespace.SplashScreen self, Java.Interop.JniArgumentValue* parameters) in 
Android.App.Activity.OnCreate(Android.OS.Bundle savedInstanceState) in 
MvvmCross.Droid.Support.V7.AppCompat.EventSource.MvxEventSourceAppCompatActivity.OnCreate(Android.OS.Bundle bundle) in 
MvvmCross.Droid.Support.V7.AppCompat.MvxAppCompatActivity.OnCreate(Android.OS.Bundle bundle) in 
MvvmCross.Droid.Support.V7.AppCompat.MvxSplashScreenAppCompatActivity.OnCreate(Android.OS.Bundle bundle) in 
Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) in 
object.11() in 
jonathanpeppers commented 5 years ago

@SamuelDebruyn the build log (or if your willing to zip up/share the contents of your obj directory) would help more that what you are seeing at runtime.

In either case, @SamuelDebruyn do you think it could be related to the VS for Mac issue mentioned here?

Let's say you make a change to your project, in many cases you will see the notification area say Updating Resources.. or the Xamarin.Forms equivalent. (It might say Updating Xaml... or something?)

Currently, if you build (hit the play button) while this operation is happening, two msbuild's run at once, which can corrupt the obj directory. This issue is being worked on/tracked internally. This is not an issue on VS Windows, but hopefully this can be fixed in VS for Mac soon.

If it is random, this sounds like it could be the culprit?

sdebruyn commented 5 years ago

@jonathanpeppers I updated my comment with the buildlog :)

Could be, but not sure. @MaximST92 thinks it's related to actions in git.

MaximST92 commented 5 years ago

I think it has something to do with moving resources from one project to another project in the same solution.

jonathanpeppers commented 5 years ago

@MaximST92 so that sounds like something we should try.

Are you moving them from a Xamarin.Android library project to another library project?

MaximST92 commented 5 years ago

like this example: DroidProjectA resources to DroidProjectShared

sdebruyn commented 5 years ago

This is a mayor annoyance. 1 out of 5 builds fails with these kind of crashes. Sad to see you've marked this as "far future". Means that development with Xamarin.Android will be a PITA until the far future?

sdebruyn commented 5 years ago

@jonathanpeppers If you send me an email with your bitbucket username (sam.debruyn@3factr.be) I can give you access to our repo so that you can experience this yourself.

jonathanpeppers commented 5 years ago

@SamuelDebruyn I believe your issue is related to the VS for Mac issue mentioned here.

They have fixed this in VS for Mac 2019. The change is in a private repo, or I could link to it.

Do you have repro steps for what you are seeing? I can try a File -> New project first with the latest VS for Mac bits.

sdebruyn commented 5 years ago

I'm afraid I don't have a repro for this. I know it happens consistently about 1 out of 5 times on one of the projects I'm working on. Is the change available in the latest public version of VS 2019? I'll try that.

jonathanpeppers commented 5 years ago

Try it and let me know, it might be coming next preview, because they didn't fix it that long ago.

jonathanpeppers commented 5 years ago

@regisramillien / @SamuelDebruyn

Visual Studio for Mac 7.8 preview has a fix for an issue related to this: https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-mac-preview-relnotes#xamarinandroid-1

I've had one developer tell me their problems were solved when updating, let me know if that works for you!

jonathanpeppers commented 5 years ago

We have several fixes that I think address this:

These will be in a future VS 2019 Release (16.1, perhaps?)

Try out the VS 2019 previews and let me know if you folks are still hitting this, thanks!