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

Enabling proguard in d15-7 now causes ClassNotFoundException on startup #1373

Closed
pjcollins opened this issue Mar 6, 2018 · 6 comments
Closed
Labels
Area: App Runtime Issues in `libmonodroid.so`. vs-sync For internal use only; creates a VSTS "mirror" issue.
Milestone

Comments

@pjcollins
Copy link
Member

pjcollins commented Mar 6, 2018

Projects which enable proguard are crashing on startup when using d15-7. This is a regression as compared to d15-6.

This 'behavior' was previously reported as #1331, however the stack trace encountered in that instance was different than in this new failure. I've attached an .apk file as well as the intermediate output of that build.

Steps to Reproduce

  1. msbuild /t:Install /p:Configuration=Release /p:EnableProguard=true *.csproj

Release.zip

App29.App29-Signed.zip

Version Information

Xamarin.Android SDK 8.3.0.1

Log File

03-06 14:14:38.374 30948 30948 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{App29.App29/md5cccdd53e8348812fe1f2fce1387c090e.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "md5cccdd53e8348812fe1f2fce1387c090e.MainActivity" on path: DexPathList[[zip file "/data/app/App29.App29-eAar8WzCugsoi-6aT68DbA==/base.apk"],nativeLibraryDirectories=[/data/app/App29.App29-eAar8WzCugsoi-6aT68DbA==/lib/arm, /system/fake-libs, /data/app/App29.App29-eAar8WzCugsoi-6aT68DbA==/base.apk!/lib/armeabi-v7a, /system/lib]]
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.app.ActivityThread.-wrap11(Unknown Source:0)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6494)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
03-06 14:14:38.374 30948 30948 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "md5cccdd53e8348812fe1f2fce1387c090e.MainActivity" on path: DexPathList[[zip file "/data/app/App29.App29-eAar8WzCugsoi-6aT68DbA==/base.apk"],nativeLibraryDirectories=[/data/app/App29.App29-eAar8WzCugsoi-6aT68DbA==/lib/arm, /system/fake-libs, /data/app/App29.App29-eAar8WzCugsoi-6aT68DbA==/base.apk!/lib/armeabi-v7a, /system/lib]]
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
03-06 14:14:38.374 30948 30948 E AndroidRuntime:        ... 9 more
03-06 14:14:38.378 30948 30982 D libEGL  : loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
03-06 14:14:38.386  1163 10565 W ActivityManager:   Force finishing activity App29.App29/md5cccdd53e8348812fe1f2fce1387c090e.MainActivity
03-06 14:14:38.388  1163  1178 I ActivityManager: Showing crash dialog for package App29.App29 u0

VS bug #578898

@pjcollins pjcollins added the bug Component does not function as intended. label Mar 6, 2018
@pjcollins pjcollins added this to the d15-7 milestone Mar 6, 2018
@pjcollins pjcollins added Area: App Runtime Issues in `libmonodroid.so`. regression and removed bug Component does not function as intended. labels Mar 6, 2018
@atsushieno
Copy link
Contributor

You forgot to attach the sources, those archives are both build artifacts.

@atsushieno
Copy link
Contributor

Also, the last time I touched Proguard task was like Oct. 2016. It's more about MSBuild tasks, so @dellis1972 and probably @jonathanpeppers (who made the last commit) would know what happened there. https://github.com/xamarin/xamarin-android/commits/master/src/Xamarin.Android.Build.Tasks/Tasks/Proguard.cs

@pjcollins
Copy link
Member Author

@atsushieno sorry for not including source, from what I have seen this reproduces with any project. Here's a simple demo that can be used:
https://github.com/xamarin/monodroid-samples/tree/master/Button

@jonathanpeppers
Copy link
Member

Hey guys, it looks like the same commits for the <Proguard /> MSBuild task are on 15.6: https://github.com/xamarin/xamarin-android/commits/d15-6/src/Xamarin.Android.Build.Tasks/Tasks/Proguard.cs

So I guess it means the issue lies somewhere else? I will be coming back from parental leave part time on Monday, I can probably take a deeper look then if someone else hasn't yet.

@jonpryor jonpryor added the vs-sync For internal use only; creates a VSTS "mirror" issue. label Mar 8, 2018
@jonathanpeppers
Copy link
Member

This is indeed a fallout from #1131 -- something that was added for 15.7 right before I went on leave.

It looks like this for-loop needs changed, since acw-map.txt has less lines: https://github.com/xamarin/xamarin-android/blob/89b524c2929c2e743c60038fa9623869cffa2505/src/Xamarin.Android.Build.Tasks/Tasks/Proguard.cs#L133

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Mar 12, 2018
…-map.txt file

Fixes dotnet#1373

Since dotnet#1131, the contents of the `acw-map.txt` file have changed. We
have removed the fully qualified type names from the file, and there is
some code in the `<Proguard />` task that relies on a specific number of
lines per C# type.

We need to update the for-loop to skip every third line instead of every
fourth line.

I also updated the loop to only index against the `acwLines` array once
per loop interation, as a small performance improvement. The code is also
a little more readable from this change.

Lastly, I added some code to the proguard test so that it validates the
proguard configuration file contains the appropriate contents. Prior to
this, the test was only making sure the build succeeded.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Mar 12, 2018
…-map.txt file

Fixes dotnet#1373

Since dotnet#1131, the contents of the `acw-map.txt` file have changed. We
have removed the fully qualified type names from the file, and there is
some code in the `<Proguard />` task that relies on a specific number of
lines per C# type.

We need to update the for-loop to skip every third line instead of every
fourth line.

I also updated the loop to only index against the `acwLines` array once
per loop interation, as a small performance improvement. The code is also
a little more readable from this change.

Lastly, I added some code to the proguard test so that it validates the
proguard configuration file contains the appropriate contents. Prior to
this, the test was only making sure the build succeeded.
jonpryor pushed a commit that referenced this issue Mar 13, 2018
Fixes: #1373

Since e5b1c92, the contents of the `acw-map.txt` file have changed. We
have removed the fully qualified type names from the file, and there is
some code in the `<Proguard />` task that relies on a specific number of
lines per C# type.

We need to update the for-loop to skip every third line instead of every
fourth line.

I also updated the loop to only index against the `acwLines` array once
per loop interation, as a small performance improvement. The code is also
a little more readable from this change.

Lastly, I added some code to the proguard test so that it validates the
proguard configuration file contains the appropriate contents. Prior to
this, the test was only making sure the build succeeded.
jonpryor pushed a commit that referenced this issue Mar 16, 2018
Fixes: #1373

Since e5b1c92, the contents of the `acw-map.txt` file have changed. We
have removed the fully qualified type names from the file, and there is
some code in the `<Proguard />` task that relies on a specific number of
lines per C# type.

We need to update the for-loop to skip every third line instead of every
fourth line.

I also updated the loop to only index against the `acwLines` array once
per loop interation, as a small performance improvement. The code is also
a little more readable from this change.

Lastly, I added some code to the proguard test so that it validates the
proguard configuration file contains the appropriate contents. Prior to
this, the test was only making sure the build succeeded.
@pjcollins
Copy link
Member Author

Verified fixed in XA 8.3.0.10.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App Runtime Issues in `libmonodroid.so`. vs-sync For internal use only; creates a VSTS "mirror" issue.
Projects
None yet
Development

No branches or pull requests

5 participants