Bug 51695 - MSBuild Task "Proguard" : Inner classes not preserved in generated ./proguard/proguard_project_primary.cfg
Summary: MSBuild Task "Proguard" : Inner classes not preserved in generated ./proguard...
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.1 (C9)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: dean.ellis
Depends on:
Reported: 2017-01-23 04:31 UTC by RobertN
Modified: 2017-08-23 21:09 UTC (History)
3 users (show)

Tags: bb
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description RobertN 2017-01-23 04:31:02 UTC
In the coding example of:

     namespace LiveGallery
	public class LiveGalleryWallpaperService : WallpaperService
		class LiveGalleryEngine : Engine

The generated Java wrapper is:

      package com.sushhangover.livegallery;
        public class LiveGalleryService extends android.service.wallpaper.WallpaperService
           public class LiveGalleryWallpaperService_LiveGalleryEngine extends android.service.wallpaper.WallpaperService.Engine  implements mono.android.IGCUserPeer

Enabling Proguard, the generated ./proguard/proguard_project_primary.cfg contains

     -keep class md5374f575086bad00a82d38df690d6cb33.MainActivity { *; }
     -keep class com.sushhangover.livegallery.LiveGalleryService { *; }
     -keep class com.sushhangover.livegallery.LiveGalleryPreferencesActivity { *; }

Resulting in:

     [AndroidRuntime] Shutting down VM
     [AndroidRuntime] FATAL EXCEPTION: main
     [AndroidRuntime] Process: com.sushhangover.livegallery, PID: 17007
     [AndroidRuntime] java.lang.NoSuchMethodError: no non-static method "Lcom/sushhangover/livegallery/LiveGalleryService$LiveGalleryWallpaperService_LiveGalleryEngine;.<init>(Lcom/sushhangover/livegallery/LiveGalleryService;)V"
     [AndroidRuntime] 	at com.sushhangover.livegallery.LiveGalleryService.n_onCreateEngine(Native Method)
     [AndroidRuntime] 	at com.sushhangover.livegallery.LiveGalleryService.onCreateEngine(LiveGalleryService.java:37)
     [AndroidRuntime] 	at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:1160)
     [AndroidRuntime] 	at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:37)
     [AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:102)
     [AndroidRuntime] 	at android.os.Looper.loop(Looper.java:148)
     [AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:5417)
     [AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
     [AndroidRuntime] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
     [AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

You must manually add a proguard configuration <ProguardConfiguration> to the project to preserve your innerclass <init>


    -keep public class com.sushhangover.livegallery.LiveGalleryService$LiveGalleryWallpaperService_LiveGalleryEngine { <init>(...); }
Comment 1 Tom Opgenorth 2017-06-27 17:23:21 UTC
Thank you for taking the time to submit the bug. We are unable to reproduce this issue. Please attach a reproduction to the bug by starting with a clean Xamarin.Android project and adding just the code necessary to demonstrate the issue.
Comment 2 Cody Beyer (MSFT) 2017-08-23 21:09:31 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!