how do I setup Android studio for IOIOActivity

120 views
Skip to first unread message

Ilan Tal

unread,
Feb 18, 2016, 5:40:27 AM2/18/16
to ioio-users
I've got a trivial Android project running under Android studio. After going through tutorials I set up my own project which works.

The next step was to try to hook up the ioio board. I tried HelloIOIO, IOIOSimpleApp and HelloIOIOService, none of which I could get to work. It complained about not finding android-7, which after messing about, changing compileSdkVersion to 23 and a couple of other things which I can't remember.

In the end the application stopped because it couldn't connect. I went back to my own application which was still working fine. So I decided to make my own new application.

import android.os.Bundle;
import ioio.*;

public class MainActivity extends IOIOActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

As soon as I changed the extends Activity to extends IOIOActivity it had no idea what IOIOActivity was.
Do I have to somehow point to IOIOLibCore-5.07.jar, IOIOLibAndroid-5.07.aar or what?
Where and how do I tell it to pick up what is missing?

Thanks,
Ilan


Ilan Tal

unread,
Feb 18, 2016, 6:08:56 AM2/18/16
to ioio-users
I finally found it GradleScripts -> build.gradle(Module app)

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.github.ytai.ioio:IOIOLibAndroid:5.07'
compile 'com.github.ytai.ioio:IOIOLibAndroidBluetooth:5.07'
compile 'com.github.ytai.ioio:IOIOLibAndroidAccessory:5.07'
compile 'com.github.ytai.ioio:IOIOLibAndroidDevice:5.07'
}

repositories {
mavenCentral()
}
I added the 5.07 dependencies and the repository of mavenCentral. I could probably remove the com.android.support:appcompat-v7:23.1.1 but I'll leave it.
Now I'll see if I can get it to connect to the emulator.

Ilan Tal

unread,
Feb 18, 2016, 7:15:44 AM2/18/16
to ioio-users
No such luck that it would actually work. I went back and downloaded App-IOIO0507.zip and tried again. Now I already knew how to change

android {
buildToolsVersion "23.0.2"
compileSdkVersion 23
}
from compile version 19 to 23. That got rid of my SDK errors, but there is a strange error in the comment of all places

class Looper extends BaseIOIOLooper {
/** The on-board LED. */
private DigitalOutput led_;

/**
* Called every time a connection with IOIO has been established.
* Typically used to open pins.
*
* @throws ConnectionLostException
* When IOIO connection is lost.
*
* @see ioio.lib.util.IOIOLooper#setup()
*/

It can't resolve IOIOLooper#setup and setup is red. This may just be a red herring as who ever heard of an error inside a comment?
In any case it fails

 E/AndroidRuntime: FATAL EXCEPTION: main
                       Process: ioio.examples.hello, PID: 4221
                        java.lang.RuntimeException: Unable to start activity ComponentInfo{ioio.examples.hello/ioio.examples.hello.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void android.hardware.usb.IUsbManager.getDeviceList(android.os.Bundle)' on a null object reference
                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)

It isn't clear to me what has failed. Is it something in ioio or android.hardware.usb? It appears again as

 Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void android.hardware.usb.IUsbManager.getDeviceList(android.os.Bundle)' on a null object reference
                                                                       at android.hardware.usb.UsbManager.getDeviceList(UsbManager.java:295)

I am using an IOIO bridge to talk between the ioio and the emulator and it works on the simple android test program which I wrote. The test program doesn't do anything with the ioio board
itself, so I am trying to take the next step. Until I figure out what is killing me, there isn't much I can do.
Reply all
Reply to author
Forward
0 new messages