2

I am trying to get an Android Things project to build and run on a Raspberry Pi 3. The files are found here. I am connected to my Raspberry Pi 3 via Ethernet. I plugged the ethernet cable directly from my laptop to the rPi and used Internet Sharing. I then used adb connect to connect to the device and it successfully connects.

I am running:

Android Studio 3.1.2
Build #AI-173.4720617, built on April 13, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

Changes were made to Android Studio so I had to change some code around. I downloaded the files and updated the PeripheralManagerService to PeripheralManager instead.

PeripheralManager pioService = PeripheralManager.getInstance();

When I click the Run button, I get the following error (please keep in mind that I already added the following permission to Android Manifest file above the application section):

<uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO"/>

Please help me with figure out what I am still missing. Thanks!

06-08 01:43:28.746 3598-3598/? I/zygote: Late-enabling -Xcheck:jni 06-08 01:43:28.993 3598-3598/apps.hackstermia.buttonthings I/MainActivity: Starting ButtonActivity
06-08 01:43:29.013 3598-3598/apps.hackstermia.buttonthings I/MainActivity: Configuring GPIO pins
06-08 01:43:29.017 3598-3598/apps.hackstermia.buttonthings D/AndroidRuntime: Shutting down VM
06-08 01:43:29.028 3598-3598/apps.hackstermia.buttonthings E/AndroidRuntime: FATAL EXCEPTION: main
    Process: apps.hackstermia.buttonthings, PID: 3598
    java.lang.RuntimeException: Unable to start activity ComponentInfo{apps.hackstermia.buttonthings/apps.hackstermia.buttonthings.MainActivity}: java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.USE_PERIPHERAL_IO
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        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)
     Caused by: 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 apps.hackstermia.buttonthings.MainActivity.onCreate(MainActivity.java:26)
        at android.app.Activity.performCreate(Activity.java:7010)
        at android.app.Activity.performCreate(Activity.java:7001)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        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) 
06-08 01:43:29.047 3598-3598/apps.hackstermia.buttonthings I/Process: Sending signal. PID: 3598 SIG: 9
Zoe
  • 27,060
  • 21
  • 118
  • 148
Bob R.
  • 21
  • 1
  • 4
  • Possible duplicate of [Android permission doesn't work even if I have declared it](https://stackoverflow.com/questions/32635704/android-permission-doesnt-work-even-if-i-have-declared-it) – Zoe Jun 08 '18 at 12:56
  • 1
    @Zoe, no. You shouldn't think Android Things works exactly like Android for mobile devices. – Onik Jun 08 '18 at 20:12

5 Answers5

3

At first, following lines should be included by AndroidManifest just before application tag

<uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO" />
<uses-permission android:name="com.google.android.things.permission.MANAGE_INPUT_DRIVERS" />

Then, if you install application via adb, you should install <APK> with -g option as follow as recomended by @Devunwired here

adb install -g <APK>
ierturk
  • 452
  • 6
  • 22
2

friends~!

I had the same problem with my Android Studio 3.1.3 and RaspberryPi 3 and AndroidThings. This platform was killing my "blink" app, because I had a lacks permission of "[..] USE_PERIPHERAL_IO".

For my problem, the solution was adding this sentence:

<uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO"/>
<uses-permission android:name="com.google.android.things.permission.MANAGE_INPUT_DRIVERS" />

to my Android Manifest file.

Thanks, anyone for help :))

Danielx909
  • 21
  • 2
0

Thanks for your input everyone.

I found out that the permission in the manifest file needs to be a direct child, or outside of the application

Bob R.
  • 21
  • 1
  • 4
0

I had the same issue. Tried different approaches as mentioned above. What really works for me 1. update your android studio to the latest version. Mine was 3.0.1. After upgrade, it is 3.1.3 2. update the os version of android things to the latest. It was 0.6. After upgrade, it is 1.0.1. 3. Set those permission in android manifest <uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO"/> <uses-permission android:name="com.google.android.things.permission.MANAGE_INPUT_DRIVERS" />

hope those steps will make your android things working

Liangjun
  • 601
  • 4
  • 13
-1

Depending on the version of Android Studio, the prisons are applied and granted on upgrades and installs or only on installs (on older versions)

Rebooting the device should fix it, uninstalling and reinstalling the app should also fix it.

shalafi
  • 3,926
  • 2
  • 23
  • 27