Android Question B4A Sdk Manager Error

CStorSupport

Member
Licensed User
Longtime User
I tried searching this forum and Google for a fix and found a reply saying I should 'update my jre'.
So I tried searching for 'jre download' and couldn't find anything, at least, that I could understand.
I'm feeling a little dense right now.
Any help would be much appreciated.

Attached is a screenshot of the error.
 

Attachments

  • B4A Sdk Manager Error.png
    B4A Sdk Manager Error.png
    36.7 KB · Views: 75
Solution
I pasted your Try/Catch in my Activity_Resume but both Starter.rp lines show the error "Unknown member:rp".
And as I posted above I updated my Manifest with
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
Do I also need the Try/Catch in Activity_Resume?
And if so, how do I solve the error?
My apologies for my inexperience and thanks for your help.
see the attached project

Sagenut

Expert
Licensed User
Longtime User
Wharf you did before getting this error?
Have you updated B4A?
From an older version?
Which one?
I would suggest to redownload and reinstall everything (B4A, Android SDK, Java) following carefully all the steps in the installation guide.
From here
https://www.b4x.com/b4a.html
 
Upvote 0

CStorSupport

Member
Licensed User
Longtime User
Thank you all for your speedy reply!

Scantech, thanks for your reply. I was going to try that but the likelihood of more holes in my old app made me want to clean my slate and go with Sagenut's suggestion.

So, I reinstalled everything: B4A, Android SDK, Java, following carefully all the steps in https://www.b4x.com/b4a.html

Here's the problem:
Main code:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        Log(pid.GetLine1Number) 'actually line # 495

It bombs when trying to retrieve the phones #.

The error as shown in the Logger:
...​
Copying updated assets files (10)​
** Activity (main) Create (first time) **​
Error occurred on line: 495 (Main)​
java.lang.SecurityException: getLine1NumberForDisplay: Neither user 10455 nor current process has android.permission.READ_PHONE_STATE, android.permission.READ_SMS, or android.permission.READ_PHONE_NUMBERS​

Project Attributes:
#Region  Project Attributes
    #ApplicationLabel: Tech Activities
    #VersionCode: 52
    #VersionName: Application.VersionName
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
    #AdditionalJar: com.google.android.gms:play-services-vision
    #BridgeLogger: true
    #FullScreen: True
    #IncludeTitle: False
    #MultiDex: True
#End Region

Attached is, I think, everything else you may want to know about my environment.
 

Attachments

  • Manifest.txt
    849 bytes · Views: 57
  • Paths Config.png
    Paths Config.png
    15.9 KB · Views: 61
  • Sdk Manager.png
    Sdk Manager.png
    37.5 KB · Views: 56
  • B4A Beta.png
    B4A Beta.png
    8.9 KB · Views: 62
  • Libraries Manager.png
    Libraries Manager.png
    18.9 KB · Views: 60
Upvote 0

CStorSupport

Member
Licensed User
Longtime User
Will do.

1st, I rebooted.

Deleted the C:\Android4 folder and made a new C:\Android4 folder.

I went back to
and downloaded the links again for the Android SDK and used 7Zip to extract
and
to C:\Android4

Decided to create a new, default project using File > New > Default.

Updated my Manifest with
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />

Added the Phone 2.60 library
While doing this I noticed the Core library version reads a 12.80.
But Help > About reads Version: 13.00 BETA #1 (64 bit)

Verified my paths:
C:\Java\jdk-19.0.2\bin\javac.exe
and
C:\Android4\platforms\android-34\android.jar

Opened SDK Manager to install any recommended items.

Saved, closed project, re-opened it.

Started B4A Bridge on my Motorola one 5G UW ace,
connected through Tools > B4A Bridge > Connect, the status bar then reading 'Connected'.

Clicked Run tool on toolbar, bombed on Log(pid.GetLine1Number).

Activity_Create:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    Dim pid As PhoneId
    If FirstTime Then
        Log(pid.GetLine1Number)
    End If
End Sub

Attached is the contents of the Logger pane.

Thank you for your help.
 

Attachments

  • Full Logger contents.txt
    2 KB · Views: 52
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Will do.

1st, I rebooted.

Deleted the C:\Android4 folder and made a new C:\Android4 folder.

I went back to
and downloaded the links again for the Android SDK and used 7Zip to extract
and
to C:\Android4

Decided to create a new, default project using File > New > Default.

Updated my Manifest with
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />

Added the Phone 2.60 library
While doing this I noticed the Core library version reads a 12.80.
But Help > About reads Version: 13.00 BETA #1 (64 bit)

Verified my paths:
C:\Java\jdk-19.0.2\bin\javac.exe
and
C:\Android4\platforms\android-34\android.jar

Opened SDK Manager to install any recommended items.

Saved, closed project, re-opened it.

Started B4A Bridge on my Motorola one 5G UW ace,
connected through Tools > B4A Bridge > Connect, the status bar then reading 'Connected'.

Clicked Run tool on toolbar, bombed on Log(pid.GetLine1Number).

Activity_Create:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    Dim pid As PhoneId
    If FirstTime Then
        Log(pid.GetLine1Number)
    End If
End Sub

Attached is the contents of the Logger pane.

Thank you for your help.
You are missing these permissions

B4X:
Sub Activity_Resume
    Try
        Dim ph As PhoneId
       
        Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)
       
        Starter.rp.CheckAndRequest("android.permission.READ_PHONE_NUMBERS")
        Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
        If Result Then
            LogColor("phone #=" & ph.GetLine1Number, Colors.red)
        End If
       
    Catch
        Log(LastException)
    End Try
End Sub
 
Upvote 0

CStorSupport

Member
Licensed User
Longtime User
I pasted your Try/Catch in my Activity_Resume but both Starter.rp lines show the error "Unknown member:rp".
And as I posted above I updated my Manifest with
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
Do I also need the Try/Catch in Activity_Resume?
And if so, how do I solve the error?
My apologies for my inexperience and thanks for your help.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I pasted your Try/Catch in my Activity_Resume but both Starter.rp lines show the error "Unknown member:rp".
And as I posted above I updated my Manifest with
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
Do I also need the Try/Catch in Activity_Resume?
And if so, how do I solve the error?
My apologies for my inexperience and thanks for your help.
You have to select the Runtime Permission library and then declare
B4X:
Private rp as RuntimePermissions
In Process Globals
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Do I also need the Try/Catch in Activity_Resume?
Activity_Resume it's not the best place where to request permissions.
You should request permissions just before the functions that will need certain permissions.
Or you can make a separate sub where to request all the permissions in a row at the beginning of the app.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I would also suggest you to start making B4XPages projects instead of Default Activity projects.
This is not mandatory but it will give you many benefits.
Search something on the forum about pro and cons.
 
Upvote 0

CStorSupport

Member
Licensed User
Longtime User
I remarked my code:
My Code:
'    Dim pid As PhoneId
'    If FirstTime Then
'        Log(pid.GetLine1Number)
'    End If
I included the Runtime Permission library and it automatically moves to the top and is check-marked.
I did this
Sub Process_Globals:
Private rp As RuntimePermissions
Now the Logs show
Unknown member: rp​
Unknown member: rp​
Unknown type: runtimepermission​
Are you missing a library reference?​
Library 'RuntimePermissions' is not used. (warning #32)​

So I tried moving the Try/Catch out of Activity_Resume and up to Activity_Create.
No change, still showing the same errors and warning.

Just on the off-chance that something might change
I decided to connect to my phone and try a run.
Maybe something impossible might happen and jump past the errors and actually work.
Of course not.

The Compiler showed
B4A Version: 13.00 BETA #1​
Parsing code. (0.00s)​
Java Version: 19​
Building folders structure. (0.02s)​
Compiling code. Error​
Error compiling program.​
Error description: Unknown member: rp​
Error occurred on line: 35​
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)​
Word: rp​

And now the Logs show
Unknown member: rp​
Unknown member: rp​
Variable 'rp' is never assigned any value. (warning #10)​

So I changed
Private rp As RuntimePermissions​
to
Public rp As RuntimePermissions​
And now the Logs only show
Unknown member: rp​
Unknown member: rp​
Both Starter.rp lines still show the error "Unknown member:rp".
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
I pasted your Try/Catch in my Activity_Resume but both Starter.rp lines show the error "Unknown member:rp".
And as I posted above I updated my Manifest with
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
Do I also need the Try/Catch in Activity_Resume?
And if so, how do I solve the error?
My apologies for my inexperience and thanks for your help.
Take a look on line 9 - thiis is my Starter code

B4X:
#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Public rp As RuntimePermissions
End Sub

Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.

End Sub

Sub Service_Start (StartingIntent As Intent)
    Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End Sub

Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy

End Sub
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
I pasted your Try/Catch in my Activity_Resume but both Starter.rp lines show the error "Unknown member:rp".
And as I posted above I updated my Manifest with
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
Do I also need the Try/Catch in Activity_Resume?
And if so, how do I solve the error?
My apologies for my inexperience and thanks for your help.
see the attached project
 

Attachments

  • Phone 07-20-2024.zip
    9.2 KB · Views: 53
Upvote 1
Solution
Top