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

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I am trying to wrap NotificationCompat.MediaStyle and it seems to compile fine but the application crashes immediately with this log



B4X:
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

B4X:
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
 

DonManfred

Expert
Licensed User
Longtime User

somed3v3loper

Well-Known Member
Licensed User
Longtime User

somed3v3loper

Well-Known Member
Licensed User
Longtime User
the same error??? Really?
I think so :

B4X:
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
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
yes, looks identical.



Try com.android.support.media2
Note that you should download the artifact in the SDK Manager too
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
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Works fine here:
B4X:
#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.
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Works fine here:
B4X:
#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.
Now I am getting this which seems to be the same :(
Is B4A 6.50 a problem here ?
B4X:
** 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)
 
Top