Upvote 1

Custom Plug-in Using Android Studio

Under Consideration Munifrogger 2 months ago

Your online instructions for preparing the API using eclipse did not match the dialogs I was seeing (at least not for MacOS). So, since I had to figure it out for myself anyway, I did so using my preferred Android Studio. Here are the steps I had to do:

Prepare Android Studio for JustInMind (JIM) SDK (See https://stackoverflow.com/a/35241990)

  1. Launch Android Studio
  2. Add new module for JIM plugin (`File` > `New` > `New Module…`)
  3. Create a folder called `libs` within that module
  4. Place the JIM SDK within `libs` folder
  5. Expand `Project` Tab/View
  6. Set view type as `Project` (as opposed to `Android`)
  7. Expand `libs/javafx` folder
  8. Right-click each of the JAR files
  9. Click `Add as Library…`
  10. Select the new module for Add to module:`
  11. Expand `libs/api_plugins` folder
  12. Right-click each of the JAR files
  13. Click `Add as Library…`
  14. Select the new module for Add to module:`
  15. Wait for Android Studio to resolve the imports in the example code (`com.justinmind.pcontrols.ControlUtils` did not resolve for me)

Configure JIM for debugging (same as your instructions; included for completeness)

  1. Edit `/Applications/Justinmind.app/Contents/Java/Justinmind.cfg`
  2. Place within `JVMOptions`: `-agentlib:jdwp=transport=dt_socket,address=9000,server=y,suspend=n`
  3. Launch JustInMind application
  4. Click on `Plug-ins` > `Install a plug-in...`
  5. Specify the location of the JAR built from this code (`build/libs/[module].jar`)

Update the plug-in after each JAR change

  1. Copy the output JAR from module to JIM application
  2. From: `[module]/build/libs/[module].jar`
  3. To: `/Applications/Justinmind.app/Contents/Java/user_plugins/[module].jar`
  4. Re-launch JIM application

Active debugging:

  1. Within Android Studio, `Run` > `Attach to Process...`
  2. Select the JustInMind process
  3. Watch for `Debug` > `Console` to print "Connected to the target VM, address: pid ####"
  4. Specify breakpoints
  5. Within JustInMind, click `Plug-ins` > `[Module]` (whatever you specified in `getName()` in your code)
  6. Now you can step through your code

Leave a Comment
Attach a file