title: How to fix java.lang.SecurityException: Caller lacks required permission com.google.android.things.permission.USE_PERIPHERAL_IO error?
body: <p>I am trying to get an Android Things project to build and run on a Raspberry Pi 3. The files are found <a href="https://github.com/brandmooffin/ButtonThings/tree/part-1_led_blink" rel="nofollow noreferrer">here</a>. 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.</p>
  
  <p>I am running:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Changes were made to Android Studio so I had to change some code around. I downloaded the files and updated the <code>PeripheralManagerService</code> to <code>PeripheralManager</code> instead.</p>
  
  <pre><code>PeripheralManager pioService = PeripheralManager.getInstance();
  </code></pre>
  
  <p>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):</p>
  
  <pre><code>&lt;uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO"/&gt;
  </code></pre>
  
  <p>Please help me with figure out what I am still missing. Thanks!</p>
  
  <pre><code>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.&lt;init&gt;(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
  </code></pre>