I have installed Android Things 1.0.1 to Raspberry Pi 3. I am using B4A 8.3, Core (Version 8.3), Things (Version 1.10). Java: jdk1.8.0_172. Android jar path: C:\Android\platforms\android-24\android.jar
I have the following code:
The manifest editor contains:
I am getting the "java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.USE_PERIPHERAL_IO" error as shown below:
I tried to solve this by rebooting the RPi several times, but getting the same error message.
Can anyone pls help? Thanks!
I have the following code:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#AdditionalJar: androidthings, ReferenceOnly
Sub Process_Globals
Private pm As PeripheralManager
Private pin4 As Gpio 'led
Private pin17 As Gpio 'button
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
pm.Initialize
Log(pm.GpioList)
pin4 = pm.OpenGpio("BCM18")
pin4.Direction = pin4.DIRECTION_OUT_INITIALLY_LOW
pin17 = pm.OpenGpio("BCM17")
pin17.Direction = pin17.DIRECTION_IN
pin17.AddListener("pin17")
End If
Activity.LoadLayout("1")
End Sub
Sub Pin17_StateChanged (Value As Boolean)
Dim clr As Int
If Value Then clr = 0xFF54EF72 Else clr = 0xFFC52D56
Activity.Color = clr
End Sub
Sub ToggleButton1_CheckedChange(Checked As Boolean)
pin4.Value = Checked 'turn on or off the led
End Sub
The manifest editor contains:
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="26"/>
<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.
AddApplicationText(<uses-library android:name="com.google.android.things"/>)
'Launch activity automatically on boot (can remove if not needed)
AddActivityText(Main,
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.IOT_LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
)
AddPermission(com.google.android.things.permission.USE_PERIPHERAL_IO)
I am getting the "java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.USE_PERIPHERAL_IO" error as shown below:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
(ArrayList) [BCM10, BCM11, BCM12, BCM13, BCM14, BCM15, BCM16, BCM17, BCM18, BCM19, BCM2, BCM20, BCM21, BCM22, BCM23, BCM24, BCM25, BCM26, BCM27, BCM3, BCM4, BCM5, BCM6, BCM7, BCM8, BCM9]
main_activity_create (java line: 350)
java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.USE_PERIPHERAL_IO
at android.os.Parcel.readException(Parcel.java:2005)
at android.os.Parcel.readException(Parcel.java:1951)
at com.google.android.things.pio.IPeripheralManagerClient$Stub$Proxy.GetGpioClient(IPeripheralManagerClient.java:759)
at com.google.android.things.pio.GpioImpl.<init>(GpioImpl.java:50)
at com.google.android.things.pio.PeripheralManager.openGpio(PeripheralManager.java:197)
at anywheresoftware.b4a.objects.PeripheralManagerWrapper.OpenGpio(PeripheralManagerWrapper.java:45)
at b4a.example.main._activity_create(main.java:350)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I tried to solve this by rebooting the RPi several times, but getting the same error message.
Can anyone pls help? Thanks!