Java Question Failed resolution of: Landroid/support/v4/media/app/NotificationCompat$MediaStyle

Discussion in 'Libraries developers questions' started by somed3v3loper, Jun 12, 2019 at 1:59 PM.

  1. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    I am trying to wrap NotificationCompat.MediaStyle and it seems to compile fine but the application crashes immediately with this log



    Code:
    starter_downloadfile (java line: 163)
    java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/media/app/NotificationCompat$MediaStyle;
        at smm.pktyle.MediaStyleBA._initialize(MediaStyleBA.java:
    55)
        at smm.pktyle.MediaStyleBA.Initialize(MediaStyleBA.java:
    45)
        at b4a.example.starter._downloadfile(starter.java:
    163)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    169)
        at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:
    897)
        at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:
    831)
        at b4a.example.main._activity_create(main.java:
    335)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    169)
        at b4a.example.main.afterFirstLayout(main.java:
    102)
        at b4a.example.main.access$
    000(main.java:17)
        at b4a.example.main$WaitForLayout.run(main.java:
    80)
        at android.os.Handler.handleCallback(Handler.java:
    873)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    193)
        at android.app.ActivityThread.main(ActivityThread.java:
    6718)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    858)
    Caused by: java.lang.ClassNotFoundException: Didn
    't find class "android.support.v4.media.app.NotificationCompat$MediaStyle" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/b4a.example-xQZ0zBa3LgeEw-RxsnHrBQ==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-xQZ0zBa3LgeEw-RxsnHrBQ==/lib/arm64, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:
    379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:
    312)

    Source code is as simple as

    Code:
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.net.Uri;
    import android.os.Environment;
    import android.util.AttributeSet;
    import android.view.MotionEvent;
    import android.view.View;
    import android.view.View.OnTouchListener;
    import android.view.ViewGroup;
    import anywheresoftware.b4a.BA;
    import anywheresoftware.b4a.BA.Events;
    import anywheresoftware.b4a.BA.Hide;
    import anywheresoftware.b4a.BA.Pixel;
    import anywheresoftware.b4a.BA.ShortName;
    import anywheresoftware.b4a.BA.Version;
    import anywheresoftware.b4a.AbsObjectWrapper;

    import anywheresoftware.b4a.BA.Author;
    import anywheresoftware.b4a.BA.DependsOn;
    import anywheresoftware.b4a.BA.ActivityObject;

    import android.support.v4.app.NotificationCompat;
    import android.support.v4.content.ContextCompat;
    import android.support.v4.media.app.NotificationCompat.MediaStyle;


    @Version(
    0.01f)
    @ShortName(
    "MediaStyle")
    @Author(
    "SMM")

    @DependsOn(values={
    "com.android.support:support-v4"})

    public class MediaStyleBA extends AbsObjectWrapper<MediaStyle>  {
        private BA ba;   
        private MediaStyle obj;
        private String eventName;
        
        public void Initialize(BA ba , String EventName ) {
            _initialize(ba,  EventName);
            
        }

        @Hide
        public void _initialize(final BA ba,String EventName) {
            this.ba = ba;
            this.eventName = EventName.toLowerCase(BA.cul);
            AttributeSet myAttributes = null;
            
            obj = new MediaStyle();
            this.setObject(obj);
            

            
        
            

        
        
        
    }

    }
    What do you suggest ?
    Sorry for asking too much these days , I am always looking for things but usually search is enough :D
     
  2. DonManfred

    DonManfred Expert Licensed User

  3. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

  4. DonManfred

    DonManfred Expert Licensed User

    the same error??? Really?

    Can you upload a small example project and the library (jar and xml)?
     
  5. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    I think so :

    Code:
    java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/media/app/NotificationCompat$MediaStyle;
        at smm.pktyle.MediaStyleBA._initialize(MediaStyleBA.java:
    55)
        at smm.pktyle.MediaStyleBA.Initialize(MediaStyleBA.java:
    45)
        at b4a.example.starter._downloadfile(starter.java:
    163)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    169)
        at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:
    897)
        at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:
    831)
        at b4a.example.main._activity_create(main.java:
    335)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    169)
        at b4a.example.main.afterFirstLayout(main.java:
    102)
        at b4a.example.main.access$
    000(main.java:17)
        at b4a.example.main$WaitForLayout.run(main.java:
    80)
        at android.os.Handler.handleCallback(Handler.java:
    873)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    193)
        at android.app.ActivityThread.main(ActivityThread.java:
    6718)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    858)
    Caused by: java.lang.ClassNotFoundException: Didn
    't find class "android.support.v4.media.app.NotificationCompat$MediaStyle" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/b4a.example-00j2LsCihrFbBqT9R9GnVA==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-00j2LsCihrFbBqT9R9GnVA==/lib/arm64, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:
    379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:
    312)
        ... 
    20 more
     
  6. DonManfred

    DonManfred Expert Licensed User

    yes, looks identical.

    [​IMG]

    Try com.android.support.media2
    Note that you should download the artifact in the SDK Manager too
     
  7. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    It is already installed
    but if I add #additionaljar:com.android.support:support-media2 , I get Maven artifact not found: com.android.support/support-media2
     
  8. DonManfred

    DonManfred Expert Licensed User

    sorry.
    Based on the artifact in the SDK Manager it must be
    com.android.support:media2
     
  9. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Same error : Maven artifact not found: com.android.support/media2
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Works fine here:
    Code:
    #additionaljar:com.android.support:support-media-compat
    Sub Process_Globals

    End Sub

    Sub Globals

    End Sub

    Sub Activity_Create(FirstTime As Boolean)
       
    Dim mediastyle As JavaObject
       mediastyle.InitializeNewInstance(
    "android.support.v4.media.app.NotificationCompat.MediaStyle"Null)
       
    Log(mediastyle)
    End Sub
    Make sure to clean the project after you add #AdditionalJar.
     
  11. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Now I am getting this which seems to be the same :(
    Is B4A 6.50 a problem here ?
    Code:
    ** Service (starter) Create **
    ** 
    Service (starter) Start **
    ** 
    Activity (main) Create, isFirst = true **
    main_activity_create (java line: 
    338)
    java.lang.ClassNotFoundException: android.support.v4.media$app$NotificationCompat$MediaStyle
        at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(
    JavaObject.java:288)
        at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(
    JavaObject.java:83)
        at b4a.example.main._activity_create(main.java:
    338)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    169)
        at b4a.example.main.afterFirstLayout(main.java:
    102)
        at b4a.example.main.access$
    000(main.java:17)
        at b4a.example.main$WaitForLayout.run(main.java:
    80)
        at android.os.Handler.handleCallback(Handler.java:
    873)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    193)
        at android.app.ActivityThread.main(ActivityThread.java:
    6718)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    858)
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    Yes.
     
  13. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Is there a workaround till I can update ?
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    B4A v6.50 doesn't support maven resources. There is no simple workaround if you want to use this resource. You can switch to the native MediaStyle that is supported from Android 5+.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice