Skip to content

Java.Lang.ClassNotFoundException: Didn't find class "android.app.PictureInPictureParams$Builder" #1125

Closed

Description

@shankar12

Steps to Reproduce

Downloaded PictureInPicture Sample from https://developer.xamarin.com/samples/monodroid/android-o/PictureInPicture/

  1. Opened the Project on VS for MAC and Restored all Packages
  2. Tried to run the project and got a runtime exception: System.NotSupportedException
    image
  3. Under System.NotSupportedException, there was Java.Lang.ClassNotFoundException

screen shot 2017-12-19 at 2 00 10 am

PictureInPicture.zip

Expected Behavior

The App Should work for PictureInPicture feature

Actual Behavior

Throws a Runtime Exception

Version Information

=== Visual Studio Community 2017 for Mac ===

Version 7.3.2 (build 12)
Installation UUID: aed07d58-dc28-46be-99a7-82fcbd01df4b
Runtime:
Mono 5.4.1.7 (2017-06/e66d9abbb27) (64-bit)
GTK+ 2.24.23 (Raleigh theme)

Package version: 504010007

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.0.0
SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks
SDK Version: 2.0.0
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

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

=== Apple Developer Tools ===

Xcode 9.1 (13532)
Build 9B55

=== Xamarin.iOS ===

Version: 11.6.1.2 (Visual Studio Community)
Hash: 6857dfcc
Branch: xcode9.2
Build date: 2017-12-04 21:20:41-0500

=== Xamarin.Android ===

Version: 8.1.0.25 (Visual Studio Community)
Android SDK: /Users/mumashankar/Library/Android/sdk
Supported Android versions:
4.4 (API level 19)
5.1 (API level 22)
6.0 (API level 23)
7.1 (API level 25)
8.0 (API level 26)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 26.0.2
SDK Build Tools Version: 26.0.2

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

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

=== Xamarin Inspector ===

Version: 1.3.2
Hash: 461f09a
Branch: 1.3-release
Build date: Tue, 03 Oct 2017 18:26:57 GMT
Client compatibility: 1

=== Xamarin.Mac ===

Version: 4.0.0.214 (Visual Studio Community)

=== Build Information ===

Release ID: 703020012
Git revision: 7d0c9d7ad46b125cf4b7bbf9532c0531b6433ce6
Build date: 2017-12-12 14:03:18-05
Xamarin addins: 6dddaa49fbecb2695fcdcd6b712eb269e288518c
Build lane: monodevelop-lion-d15-5

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
Wed Oct 4 00:17:00 PDT 2017
root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Internet of Things (IoT) development (Preview) 7.1

Log File

VSForMAC LOG.docx

Activity

  1. jonpryor commented on Dec 19, 2017

    @jonpryor
    Contributor

    On what device did you run this on? Which version of Android?

    How exactly did you interact with the program once launched? Did you rotate the screen? Hit the back button?

    I am not able to reproduce the issue.

    Could you please enable GREF logging?

    $ adb shell setprop debug.mono.log gref

    Completely quit the app, the restart it.

    When you've gotten it to crash again, grab the GREF log from the device:

    $ adb shell run-as com.xamarin.PictureInPicture cat files/.__override__/grefs.txt > grefs.txt

    Then please attach grefs.txt.


    What I'm Looking For

    I'm trying to determine where and why the wrapper was destroyed. Usually the NotSupportedException is thrown because a Java.Lang.Object instance is e.g. Dispose()d of, and then Java invokes a method which is overridden in managed code. This virtual method invocation requires that an instance exist to process the virtual method, and if a pre-existing instance doesn't exist, we attempt to create one. When we can't create one, the NotSupportedException is thrown.

    GC Bug?

    Another possibility is that this is a GC bug. Follow the link for a description of how to use the legacy GC bridge implementation.

    If this is a GC bug, please let us know. We've been trying unsuccessfully for ages to find a decent fix for that bug. Perhaps it requires a specific set of hardware?

  2. added
    need-info
    on Feb 28, 2018
  3. JonDouglas commented on May 21, 2018

    @JonDouglas
    Contributor

    I am closing this issue due to no further information being provided. See the need-info tag for more information.

  4. tuyen-vuduc commented on May 21, 2018

    @tuyen-vuduc

    Hi,

    I just faced this issue on Nexus 4, Android 19.

    The code is

        public static class MvxRecyclerViewExtensions
        {
            public static void AddLoadMoreListener(this MvxRecyclerView recyclerView, Action action)
            {
                recyclerView.SetOnScrollChangeListener(new OnScrollChangeListener(action));
            }
        }
    
        public class OnScrollChangeListener : Java.Lang.Object, View.IOnScrollChangeListener
        {
            Action action;
            public OnScrollChangeListener(Action action)
            {
                this.action = action;
            }
    
            public void OnScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY)
            {
                if (v is MvxRecyclerView recyclerView)
                {
                    if (!recyclerView.CanScrollVertically(1))
                    {
                        action?.Invoke();
                    }
                }
            }
        }
    

    And the error

    [mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.NoClassDefFoundError: md5705cc5b777d28ba1476c781645fc231a/OnScrollChangeListener ---> Java.Lang.ClassNotFoundException: Didn't find class "md5705cc5b777d28ba1476c781645fc231a.OnScrollChangeListener" on path: DexPathList[[zip file "/data/app/xxxxx-1.apk"],nativeLibraryDirectories=[/data/app-lib/xxxxx-1, /vendor/lib, /system/lib]]
    [mono-rt]    --- End of inner exception stack trace ---
    [mono-rt]   at (wrapper dynamic-method) System.Object.2f769105-8aa7-49e7-90dc-9b1e081e6013(intptr,intptr,intptr)
    [mono-rt]   --- End of managed Java.Lang.NoClassDefFoundError stack trace ---
    [mono-rt] java.lang.NoClassDefFoundError: md5705cc5b777d28ba1476c781645fc231a/OnScrollChangeListener
    [mono-rt] 	at md5a70ca10363a39e33f9fee2850b20b5da.XXX.n_onCreate(Native Method)
    [mono-rt] 	at md5a70ca10363a39e33f9fee2850b20b5da.XXX.onCreate(MyPromotionsView.java:30)
    [mono-rt] 	at android.app.Activity.performCreate(Activity.java:5231)
    [mono-rt] 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    [mono-rt] 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    [mono-rt] 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
    [mono-rt] 	at android.app.ActivityThread.access$800(ActivityThread.java:135)
    [mono-rt] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    [mono-rt] 	at android.os.Handler.dispatchMessage(Handler.java:102)
    [mono-rt] 	at android.os.Looper.loop(Looper.java:136)
    [mono-rt] 	at android.app.ActivityThread.main(ActivityThread.java:5001)
    [mono-rt] 	at java.lang.reflect.Method.invokeNative(Native Method)
    [mono-rt] 	at java.lang.reflect.Method.invoke(Method.java:515)
    [mono-rt] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    [mono-rt] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    [mono-rt] 	at dalvik.system.NativeStart.main(Native Method)
    [mono-rt] Caused by: java.lang.ClassNotFoundException: Didn't find class "md5705cc5b777d28ba1476c781645fc231a.OnScrollChangeListener" on path: DexPathList[[zip file "/data/app/xxxxx-1.apk"],nativeLibraryDirectories=[/data/app-lib/xxxxx-1, /vendor/lib, /system/lib]]
    [mono-rt] 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    [mono-rt] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    [mono-rt] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    [mono-rt] 	... 16 more
    
  5. JonDouglas commented on May 21, 2018

    @JonDouglas
    Contributor

    @tuyen-vuduc Your issue has a different class that is not being found on the dex list and thus I believe is different than this issue. Please open up a new issue with a respective reproduction project. Thank you!

  6. added a commit that references this issue on Oct 28, 2020
  7. softsan commented on Feb 28, 2022

    @softsan

    I came across this issue but it is happened when the sample is run on Android 7. As stated in Sample and also Android docs that PIP mode only support Android 8 (API 26) and later. It runs fine on those OS. So if anyone testing please make sure you use proper OS with Android device.

  8. JosiYosi commented on May 18, 2022

    @JosiYosi

    I know this issue is an old one. For those who wants to resolve the issue, check android version of a device before running PIP as the following:

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                                      boolean supportsPIP = 
                                              getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
              if(supportsPIP){
    
              
                  // if you want to set custom PIP then do like below but your ratio must be between 0.418410 and 2.390000
                  //in this case 192/108 ration is approximately 1.7777(within the required range)
                  //Note this option is only for android 13 or above
                  //Also note that it is not necessary to use aspect ration. Still you can PIP it without using aspect ratio as well.
                  //Rational aspectRatio = new Rational(192, 108);
                  Rational aspectRatio = new Rational(youTubePlayerView.getWidth(), youTubePlayerView.getHeight());
                  PictureInPictureParams params = new PictureInPictureParams.Builder()
                          .setAspectRatio(aspectRatio)// Set actions or aspect ratio.
                          .build();
                  enterPictureInPictureMode(params);
    
    
              }//end of inner if statement
    
    
        }//end of outer if statement`
    
  9. ghost locked as resolved and limited conversation to collaborators on Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions