Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=61073
Context: a296784

When we added the new classes.zip functionality, there was one oddity
present. On the first build, everything appears to be normal. On the
second build, classes.zip appeared to contain itself inside itself???

To make things even stranger, I wrote a unit test that contains a
Java.Lang.Object subclass in which its type and namespace names change
on each write. This worked fine on macOS, even with the oddity of
classes.zip continually zipping itself inside itself... The new java
sources would appear at the bottom of the list within the zip file.

Everything broke down when I tried my unit test on Windows, the case of
classes.zip trying to compress itself inside itself was silently
failing. It was not processing any further files after the failing zip
entry, and so in theory this situation would cause many Java stubs to
be missing from the zip.

Solution? Let's just put classes.zip up one directory.

So instead of:

obj/Debug/android/bin/classes/classes.zip

Move it to:

obj/Debug/android/bin/classes.zip

This prevents the classes directory from containing classes.zip, and
our strange case of classes.zip inception.

Merry Christmas! I'm going to go play Skylanders now.

@jonathanpeppers
Copy link
Member Author

cc @JonDouglas

dellis1972
dellis1972 previously approved these changes Jan 2, 2018
@dellis1972
Copy link
Contributor

@jonathanpeppers now that I think about this.. are we doing to hit an incremental clean issue here? Also does the Clean target remove the classes.zip from the new location?

@dellis1972 dellis1972 dismissed their stale review January 2, 2018 11:32

Thought about it.. changes might be needed.

@jonathanpeppers
Copy link
Member Author

The test I added is looking at the contents of the zip file, so it isn’t getting deleted....

But I didn’t check for anything explicitly keeping it, is there a wildcard that keeps everything under the obj/android folder?

@dellis1972
Copy link
Contributor

@jonathanpeppers I think the test should also do a build with No changes.. that is usually when the IncrementalClean hits us. We should also add a call to the Clean at the end and make sure the classes.zip is removed. I think we remove the entire obj/android directory if I remember rightly.. but best check to make sure we are 100% sure this is working as expected.

@erdmenchen
Copy link

Is this issue also affecting the release build process for the archive manager?

@jonpryor
Copy link
Contributor

jonpryor commented Jan 3, 2018

@erdmenchen asked:

Is this issue also affecting the release build process for the archive manager?

I do not understand the question. What archive manager?

@erdmenchen
Copy link

Since VS 15.5.2 with Xamarin.Android 8.1.0.25 I experience this issue for debug and release builds.

Submitted builds to the Google Play Store via the Visual Studio Archive Manager have the same exception as mentioned in the bugzilla bugreport.

So my question is: Does this fix also apply to the archive manager release build chain?
Currently, I am not able to release to the Play Store via the archive manager of visual studio.
Every app I submit crashes right after start with the ClassNotFound exception.

@jonpryor
Copy link
Contributor

jonpryor commented Jan 3, 2018

Does this fix also apply to the archive manager release build chain?

I believe so, yes.

Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=61073
Context: a296784

When we added the new `classes.zip` functionality, there was one oddity
present. On the first build, everything appears to be normal. On the
second build, `classes.zip` appeared to contain itself inside itself???

To make things even stranger, I wrote a unit test that contains a
`Java.Lang.Object` subclass in which its type and namespace names change
on each write. This worked fine on macOS, even with the oddity of
`classes.zip` continually zipping itself inside itself... The new java
sources would appear at the bottom of the list within the zip file.

Everything broke down when I tried my unit test on Windows, the case of
`classes.zip` trying to compress itself inside itself was silently
failing. It was not processing any further files after the failing zip
entry, and so *in theory* this situation would cause many Java stubs to
be missing from the zip.

Solution? Let's just put `classes.zip` up one directory.

So instead of:
```
obj/Debug/android/bin/classes/classes.zip
```
Move it to:
```
obj/Debug/android/bin/classes.zip
```

This prevents the `classes` directory from containing `classes.zip`, and
our strange case of `classes.zip` inception.

Merry Christmas! I'm going to go play Skylanders now.
@jonathanpeppers
Copy link
Member Author

@dellis1972 a build with no changes and a clean both seemed to work (I only have my Mac ATM).

I didn't see what is preventing IncrementalClean from deleting this file, but it seems to be doing the right thing.

I rebased against master and started a Windows build, so hopefully it works there, too.

@dellis1972 dellis1972 merged commit 008284a into dotnet:master Jan 4, 2018
jonpryor pushed a commit that referenced this pull request Jan 4, 2018
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=61073
Context: a296784

When we added the new `classes.zip` functionality, there was one oddity
present. On the first build, everything appears to be normal. On the
second build, `classes.zip` appeared to contain itself inside itself???

To make things even stranger, I wrote a unit test that contains a
`Java.Lang.Object` subclass in which its type and namespace names change
on each write. This worked fine on macOS, even with the oddity of
`classes.zip` continually zipping itself inside itself... The new java
sources would appear at the bottom of the list within the zip file.

Everything broke down when I tried my unit test on Windows, the case of
`classes.zip` trying to compress itself inside itself was silently
failing. It was not processing any further files after the failing zip
entry, and so *in theory* this situation would cause many Java stubs to
be missing from the zip.

Solution? Let's just put `classes.zip` up one directory.

So instead of:
```
obj/Debug/android/bin/classes/classes.zip
```
Move it to:
```
obj/Debug/android/bin/classes.zip
```

This prevents the `classes` directory from containing `classes.zip`, and
our strange case of `classes.zip` inception.

Merry Christmas! I'm going to go play Skylanders now.
jonpryor pushed a commit to jonpryor/xamarin-android that referenced this pull request Jan 10, 2018
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=61073
Context: a296784

When we added the new `classes.zip` functionality, there was one oddity
present. On the first build, everything appears to be normal. On the
second build, `classes.zip` appeared to contain itself inside itself???

To make things even stranger, I wrote a unit test that contains a
`Java.Lang.Object` subclass in which its type and namespace names change
on each write. This worked fine on macOS, even with the oddity of
`classes.zip` continually zipping itself inside itself... The new java
sources would appear at the bottom of the list within the zip file.

Everything broke down when I tried my unit test on Windows, the case of
`classes.zip` trying to compress itself inside itself was silently
failing. It was not processing any further files after the failing zip
entry, and so *in theory* this situation would cause many Java stubs to
be missing from the zip.

Solution? Let's just put `classes.zip` up one directory.

So instead of:
```
obj/Debug/android/bin/classes/classes.zip
```
Move it to:
```
obj/Debug/android/bin/classes.zip
```

This prevents the `classes` directory from containing `classes.zip`, and
our strange case of `classes.zip` inception.

Merry Christmas! I'm going to go play Skylanders now.
jonpryor added a commit that referenced this pull request Jan 10, 2018
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=61073
Context: a296784

When we added the new `classes.zip` functionality, there was one oddity
present. On the first build, everything appears to be normal. On the
second build, `classes.zip` appeared to contain itself inside itself???

To make things even stranger, I wrote a unit test that contains a
`Java.Lang.Object` subclass in which its type and namespace names change
on each write. This worked fine on macOS, even with the oddity of
`classes.zip` continually zipping itself inside itself... The new java
sources would appear at the bottom of the list within the zip file.

Everything broke down when I tried my unit test on Windows, the case of
`classes.zip` trying to compress itself inside itself was silently
failing. It was not processing any further files after the failing zip
entry, and so *in theory* this situation would cause many Java stubs to
be missing from the zip.

Solution? Let's just put `classes.zip` up one directory.

So instead of:
```
obj/Debug/android/bin/classes/classes.zip
```
Move it to:
```
obj/Debug/android/bin/classes.zip
```

This prevents the `classes` directory from containing `classes.zip`, and
our strange case of `classes.zip` inception.

Merry Christmas! I'm going to go play Skylanders now.
@jonathanpeppers jonathanpeppers deleted the fix-61073 branch January 18, 2018 20:36
jonpryor pushed a commit that referenced this pull request Dec 9, 2020
Context: #5331

Changes: xamarin/monodroid@0eef889...27736a7

  * xamarin/monodroid@27736a7ff: [tools/msbuild] Fix App Bundle deployment (#1142)
  * xamarin/monodroid@f38dbc7ab: [tools/msbuild] use @(_AndroidMSBuildAllProjects) (#1140)
  * xamarin/monodroid@cfa21d57b: [tools/msbuild] Fix some issues with FastDev (#1139)
  * xamarin/monodroid@3ba648386: [tools/msbuild] Add missing parameter to BuildAppBundle. (#1138)
  * xamarin/monodroid@5bb29971b: [tools/msbuild] Add Multi User Support for Debugging. (#1135)
  * xamarin/monodroid@156abf47c: [tools/msbuild] default $(_AndroidAllowDeltaInstall) to false (#1137)
  * xamarin/monodroid@fbc961218: [build] Pass EnableCompression to BuildApk (#1094)

Add support for running multi-user unit tests on device.  It makes
use of various adb commands to create test users and remove them.

Create a guest user with name `{name}`:

	adb shell pm create-user --guest {name}

Remove a guest user with the specified user id `{userId}`:

	adb shell pm remove-user --guest {userId}

Note that user creation takes a "name", while deletion takes an id.
To obtain the mapping, use:

	$ adb shell pm list users
	Users:
		UserInfo{0:Owner:c13} running
		UserInfo{10:guest1:414}

The userId is the number *between* the `{` and the `:` and user name.
The userId for `Owner` is 0, while the userId for `guest1` is 10.

We can then use a `Regex` to pull out the required `userId` for a
specific user.

To switch a device to use user `{userId}`:

	adb shell am switch-user {userId}

Emulators seem to create the main user with the name "Owner", so that
should be the default name we use for the main user.  In the unit
tests if we cannot find a user named "Owner" when looking for "Owner"
we will default to a `userId` of `0`.  User ID 0 always means the
default user.  This is to handle the case where we are testing locally
on devices where the main user is not called "Owner".
@hamzaoubouzid
Copy link

Hi everyone
i have one problem in my apps xamarin
i get url from api and i use it in source mediaelement
and when i run my apps it get me an exception

=>
Java.Lang.ClassNotFoundException: 'Didn't find class "android.media.PlaybackParams" on path: DexPathList[[zip file "/data/app/com.companyname.app16-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.app16-1/lib/x86, /vendor/lib, /system/lib]]'

so if some one can help me please

@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants