Android Question Help in a wrapper

Enxix

Member
Hello everyone.
I am developing an Exoplayer wrapper (yes, I already know what is in the forum) the idea is to learn how to do it. Because I want to make another wrapper. I did the steps right though (I think) hahaha.
The SLC tool compiles the library well and generates the files (jar and xml). But when I run the wrapper test, I get the following error.

Error:
    ... 24 more
** Activity (main) Resume **
** Activity (main) Create (first time) **
Error occurred on line: 60 (Main)
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.aisoft.radio107.ExoplayerView
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
    at com.aisoft.radio107.main._activity_create(main.java:443)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at com.aisoft.radio107.main.afterFirstLayout(main.java:105)
    at com.aisoft.radio107.main.access$000(main.java:17)
    at com.aisoft.radio107.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:280)
    at android.app.ActivityThread.main(ActivityThread.java:6706)
    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: com.aisoft.radio107.ExoplayerView
    at java.lang.Class.classForName(Native Method)

I appreciate any help. If you need the eclipse code, I will gladly pass it on to you.
I want to solve this problem. Thank you
 

MicroDrie

Well-Known Member
Licensed User
Without any source code it is difficult to pinpoint the cause with certainty. You say:

The SLC tool compiles the library well and generates the files (jar and xml)
Your setup of your SLC test development environment looks ok. How ever You don't say anything about your test environment. But if you test with, for example, a jar in the lib directory that contains the ExoplayerView class, the ExoplayerView class will not be included in your test.jar. In that case, the solution is to either include the ExoplayerView class-containing jar in your test environment, or to include the source code and all necessary classes of the ExoplayerView class-containing jar in your source (but in the second case you can difficult to talk about a wrapper).
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Its been a while since I had to write a Java library, but I remember that the trick is to create a fat jar which contains all of the jar files and their dependants.

Here is a reference to an early thread where I explain the method I used.


It was 4 years ago, so things may have changed since then, but it may point you in the right directions.
 
  • Like
Reactions: byz
Upvote 0

Enxix

Member
Hello. Thank you both for answering.
I am attaching the project in eclipse, so you can see it and tell me what I am doing wrong.
Project ExoplayerWrapper eclipse

I need to learn how to wrap because I use B4A a lot and my projects are all B4A and if in the future I need to use a 3-party library, I don't want to wait for someone to do it.

The aar files are missing. that you can download them from here.
AAR exoplayer
 
Last edited:
Upvote 0

Enxix

Member
Without any source code it is difficult to pinpoint the cause with certainty. You say:


Your setup of your SLC test development environment looks ok. How ever You don't say anything about your test environment. But if you test with, for example, a jar in the lib directory that contains the ExoplayerView class, the ExoplayerView class will not be included in your test.jar. In that case, the solution is to either include the ExoplayerView class-containing jar in your test environment, or to include the source code and all necessary classes of the ExoplayerView class-containing jar in your source (but in the second case you can difficult to talk about a wrapper).

Hello.
The ExoplayerView class is the one I am creating in the library, it is the one that cannot be found when the application is run, error post #1.
Eclipse doesn't give me any errors and neither does the SLC tool.
Attach the project with all the files necessary to find the error.
I need to know what the error was. To learn it.
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Are there any jar files in your java project's "additional" folder that you maybe did not copy to your additional library folder?

Your error shows that you are missing a class:

java.lang.RuntimeException: java.lang.ClassNotFoundException: com.aisoft.radio107.ExoplayerView

Another thing - are your package names all correct in you java project?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I want to solve this problem
I suggest to start working on the example library to understand how it works.
If you are familar with java and SLC you can try Exoplayer.
Honestly said Exoplayer is a very complex and complicating library.

I suggest to start on something different, a smaller - not so complicated - one.

 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
I'm certainly not a Java and Eclipse expert. But I see in Eclipse and in org.eclipse.jdt.core.prefs it says
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
The SLC must have at least Java version 1.8 and is the only version that produce JavaDocs that can be used in the B4A IDE.
It further states https://github.com/google/ExoPlayer:
If not enabled already, you also need to turn on Java 8 support in all build.gradle files depending on ExoPlayer, by adding the following to the android section:

compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
To avoid all kinds of differences, I use the same Java version for both SLC and the B4A IDE. By using the same Java version prepared by Erel, the AndroidX files are available, so SLC does not generate an AAR file. There was a question about this somewhere in the forum, but I cannot find it now to which external jar I should refer to.

I therefore suspect that although your source code for Eclipse and in SLC is error-free, something goes wrong with the combination between different builds of the (wrong) Java version in the final program.

I therefore fully agree with DonManfred's comment
I suggest to start on something different, a smaller - not so complicated - one.
 
Upvote 0

Enxix

Member
Hello, thank you all for responding.
And I apologize for taking so long to respond.

Reviewing the forum documentation well and seeing some examples. I was able to solve the first problem raised.

I solved it with the @ActivityObject annotation in the ExoplayerView class.

I also discovered another error.
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/collect/ImmutableMap;
ImmutableMap is at 'com.google.guava:guava:24.1-android'
I have to download the artifact or find the JAR. I haven't done any tests yet.

Thank you very much for responding.

And why have I chosen Exoplayer to practice wrapping?
The thing is that after learning well, I am going to continue with Leanback Android TV.
I'm going to need Exoplayer and Leanback when I get it to work well. I'm going to post it on the forum for other developers.
 
Upvote 0
Top