Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7124

Issue when a the version of a class in local SDK is different from compiled one

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.0-beta-3
    • 2.4.0-beta-4
    • Android
    • Tried using Groovy Android plugin on Android lower than 5.0 Lollipop. Seems to happen also on 'normal' Groovy code.

    Description

      As of Android 5.0 (API 21), Bundle (http://developer.android.com/reference/android/os/Bundle.html) class now inherits from BaseBundle (http://developer.android.com/reference/android/os/BaseBundle.html), which was added on API 21.

      As now `putInt()`, `putString()`, etc. - former Bundle methods - are methods of BaseBundle which Bundle inherits but not override, for some reason on API versions lower than 21 when you try to call those methods from a Bundle object it will throw:

      java.lang.NoClassDefFoundError: android.os.BaseBundle

      If you call its constructor, which in API 21 only does:

      public Bundle() {
      super();
      }

      It will work as Groovy still looks for the constructor on that class and while on API lower than 21 the code is different, there is no problem.

      So even when the BaseBundle class is not there Groovy still tries to call it. If you try to use those methods on a `.java` file they will work flawlessly.

      Attachments

        1. GroovyBugTest.zip
          133 kB
          Jorge Espinosa
        2. MainActivity.class
          3 kB
          Jorge Espinosa

        Activity

          People

            melix Cédric Champeau
            arasthel Jorge Espinosa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: