B4A Library Clock-View

Johan Schoeman

Expert
Licensed User
Longtime User
....maybe because you are using Java 11 and I am using Java 8
 

Johan Schoeman

Expert
Licensed User
Longtime User
I switched to java 8, the same error still there
Can you try to download and install this APK and see if it works?


It is the APK that were created when I compiled the B4A project (in the Objects folder of the B4A project)
 

Albert Kallal

Active Member
Licensed User
You don't have to do anything with the Java code. Only posted it in case someone wants to modify the library and recompile it into a new jar and xml. Have just tested it again on my device and all working fine.

Ah, very good (this is what I assumed - and it is beyond the call of duty to have included that Java code). (I feel much better - since that is exaclty what I assumed. But I also assumed that I was to modify that code to make this work.

What is inside your Files folder?

I not added or changed what the sample has. I see only the view "main.bal" layout (view) file.

I see/have this:

And inside of Files, there is as noted the main.bal layout:



I don't have anything else in that folder.

As I noted, the project does build. But we error out on 37 - this line:

B4X:
    Activity.LoadLayout("main")

And the error is as per above screen shot:
eg:



So, I was assuming that I had to modify the source to make this work.

I am using jdk-11.0.1. , build tools points to 30.0.2 (these are to my knowledge the defalults out of the box for B4A).

So, at least I am now on the right track. It obviously a build version/configuration issue in regards to my version of B4A.

I try pointing B4A to a previous version of the build tools, and see if that works.

(appreciate your follow-up). So, based on information so far, with the sample, as long as it compiles, sees the LibRes folder correctly (it does), then this should run.

Current libraries shows only 2 references:



So, as long as I grasp the idea here (I did not realize) that the given sample should run, then obviously work on my end to try some earlier versions of the SDK would be in order.

I honestly feed bad - since your instructions were clear - I just had to be 100% sure I should not need to modify this sample to run. S

Now that this assuming is clear, then I think this road comes down to trying a few different SDK's - I give this a try and see what happens.

Regards,
Albert D. Kallal
Edmonton, Alberta Canada
 

Albert Kallal

Active Member
Licensed User
B4A 10.2
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="29"/>

Ok, manifest is this:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)
'End of default text.

It compiles - upon run I get this:

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 34 (Main)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at JHS.Clock.main._activity_create(main.java:391)
    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:144)
    at JHS.Clock.main.afterFirstLayout(main.java:105)
    at JHS.Clock.main.access$000(main.java:17)
    at JHS.Clock.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:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    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.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 18 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/content/res/ResourcesCompat;
    at com.arbelkilani.clock.Clock.init(Clock.java:217)
    at com.arbelkilani.clock.Clock.<init>(Clock.java:147)
    at clockviewwrapper.clockviewWrapper._initialize(clockviewWrapper.java:92)
    ... 21 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.res.ResourcesCompat" on path: DexPathList[[zip file "/data/app/JHS.Clock-PpRbu-9ogfWms7r8gkPQmg==/base.apk"],nativeLibraryDirectories=[/data/app/JHS.Clock-PpRbu-9ogfWms7r8gkPQmg==/lib/x86_64, /system/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)
    ... 24 more
** Activity (main) Resume **

Looking at above? it looks like it can't find/resolve the external lib:
B4X:
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/content/res/ResourcesCompat;
    at com.arbelkilani.clock.Clock.init(Clock.java:217)

R
Albert
 

Johan Schoeman

Expert
Licensed User
Longtime User
Attached is the zipped B4A project (note that I have added the jar and xml to the /Files folder. Cut them (jar and xml) from this folder and paste them in your additional library folder). Have also attached LibRes.zip. Extract folder LibRes (with its contents) and copy the folder (LibRes) to be the same folder level of the B4A project's /Files and /Objects folders.
 

Attachments

  • LibRes.zip
    109.4 KB · Views: 239
  • b4aClock.zip
    188.3 KB · Views: 266

amidgeha

Active Member
Licensed User
Longtime User
B4A Version: 10.2
Java Version: 11
Parsing code. (0.00s)
Building folders structure. (0.01s)
Compiling code. (0.01s)

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. Error
invalid resource directory name: ..\libres font
 

Johan Schoeman

Expert
Licensed User
Longtime User
B4X:
B4A Version: 10.2
Java Version: 8
Parsing code.    (0.01s)
Building folders structure.    (0.02s)
Compiling code.    (0.11s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Generating R file.    (0.73s)
Compiling generated Java code.    (3.14s)
Convert byte code - optimized dex.    (5.01s)
Packaging files.    (1.04s)
Copying libraries resources    (0.01s)
Signing package file (debug key).    (1.43s)
ZipAlign file.    (0.09s)
Installing file to device.    (5.91s)
    Device serial: RF8M70NF4RL
Completed successfully.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Give 5 minutes - we will try a different approach.....
 

Johan Schoeman

Expert
Licensed User
Longtime User
See if this will compile correctly:
1. I have done away with the LibRes folder - the "font" and "values" folders are now in the B4A project's /Objects/res folder
2. When you have downloaded the attached B4A project and "unzipped" it you need to make sure that the properties of the files in the "font" and "values" foldes are set to READ ONLY before you compile the B4A project - else they will be deleted when you compile the B4A project

Let's try it and see is it works...
 

Attachments

  • b4aClock.zip
    297.3 KB · Views: 188

amidgeha

Active Member
Licensed User
Longtime User
B4A Version: 10.2
Java Version: 11
Parsing code. (0.01s)
Building folders structure. (0.01s)
Compiling code. (0.01s)

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. Error
invalid resource directory name: res font

The font and values are read only and not deleted after compilation
 

Johan Schoeman

Expert
Licensed User
Longtime User

.....no idea....is it Java 11 (you) vs Java 8 (me) that is messing us around?
 

amidgeha

Active Member
Licensed User
Longtime User
.....no idea....is it Java 11 (you) vs Java 8 (me) that is messing us around?
I Switched to Java8
B4A Version: 10.2
Java Version: 8
Parsing code. (0.01s)
Building folders structure. (0.04s)
Compiling code. (0.01s)

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. Error
invalid resource directory name: res font
 

Johan Schoeman

Expert
Licensed User
Longtime User
Something very strange going on here....I now get the same error after all the "messing around"....after I moved it to the /Object/res folder and then back to the LibRes folder...

B4X:
B4A Version: 10.2
Java Version: 8
Parsing code.    (0.00s)
Building folders structure.    (0.05s)
Compiling code.    (0.06s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Generating R file.    Error
invalid resource directory name: ..\libres fonts
 

amidgeha

Active Member
Licensed User
Longtime User
Sorry for the mess, like you said before @Erel should be able to help, I hope
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…