Android Question setscreenbrightness error

RichyK68

Active Member
Licensed User
Longtime User
Hi,
I've gone back to an old project to make a minor fix, but when I compiled and ran it it errored. So I had to go into debug and find what was causing it (nothing to do with the change I made).

B4X:
Sub SetScreenBrightness(b As Float)

    Dim p As Phone
    If b < 0.1f Then b = 0.1f
    MyFunctions.WriteSetting("screen_brightness", b * 255)
    p.SetScreenBrightness(b)

End Sub

This used to work but the line p.SetScreenBrightness(b) is now causing the following error:

B4X:
radius:2.0
elevation:2.0
** Service (notificationservice) Start **
java.lang.NoSuchFieldError: No field activityBA of type Ljava/lang/ref/WeakReference; in class Lanywheresoftware/b4a/BA; or its superclasses (declaration of 'anywheresoftware.b4a.BA' appears in /data/app/richkidsoftware.turnmeon-2/base.apk)
    at anywheresoftware.b4a.phone.Phone.SetScreenBrightness(Phone.java:183)
    at richkidsoftware.turnmeon.main._setscreenbrightness(main.java:2329)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA$2.run(BA.java:328)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
java.lang.RuntimeException: java.net.SocketException: Connection reset
    at anywheresoftware.b4a.shell.Shell$2.run(Shell.java:313)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:192)
    at java.net.SocketInputStream.read(SocketInputStream.java:120)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at java.io.DataInputStream.readByte(DataInputStream.java:265)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:333)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at anywheresoftware.b4a.shell.Shell$2.run(Shell.java:311)
    ... 7 more

My manifest, which hasn't changed, states

B4X:
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="21"/>

Paths are configured such:

javac.exe
C:\Program Files\Java\jdk1.7.0_51\bin\javac.exe

android.jar
C:\Users\Richard\AppData\Local\Android\android-sdk\platforms\android-25\android.jar

additional
C:\Program Files (x86)\Anywhere Software\Basic4android\Additional Libraries

These may have changed with projects started after this project.

Why would the set brightness command now be failing? I tried using android.jar versions 19 and 21, but neither worked.

Thanks,

Richard
 

RichyK68

Active Member
Licensed User
Longtime User
Yes :(

B4X:
Connected to B4A-Bridge (Wifi)
Connected to B4A-Bridge (Wifi)
PackageAdded: package:b4a.example
** Activity (main) Resume **
Connected to B4A-Bridge (Wifi)
Connected to B4A-Bridge (Wifi)
Connected to B4A-Bridge (Wifi)
Installing file.
** Activity (main) Pause, UserClosed = false **
Connected to B4A-Bridge (Wifi)
Connected to B4A-Bridge (Wifi)
PackageAdded: package:b4a.example
Connected to B4A-Bridge (Wifi)
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.NoSuchFieldError: No field activityBA of type Ljava/lang/ref/WeakReference; in class Lanywheresoftware/b4a/BA; or its superclasses (declaration of 'anywheresoftware.b4a.BA' appears in /data/app/b4a.example-2/base.apk)
    at anywheresoftware.b4a.phone.Phone.SetScreenBrightness(Phone.java:183)
    at b4a.example.main._activity_create(main.java:380)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    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:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
Connected to B4A-Bridge (Wifi)
 
Upvote 0
Top