General use case:
For my project I'm trying to implement several easy games like Pong or a simple quiz for Android TV. The TV respectively Android TV box displays the game and handles the logic (Separate module). Smartphones and tablets should act as simple controllers for these games (Separate module). For example: When playing Pong, the application on the phone just shows 2 arrows for moving the player's paddle up or down. For the connection and communication between the app on the TV and the app on the mobile device, the Google Nearby Connections API is used.
The actual problem:
The requirement is now that the user can start the Pong game from his phone. That means: He opens the simple controller app on his mobile device, chooses a pseudonym and then decides if he wants to start a new Pong game or if he wants to join an existing Pong game. So that when the user wants to start a pong game, he should be able to push a button on the screen and the application on the Android TV would get started (If not already running).
I did a lot of research on this and sadly had to find out that there are not much examples or source code available for this kind of feature. Luckily, I found then the source code for the official Google TV Remote application (I can not add the link as my reputation is too low yet).
I've been aware that it's an app for the older Google TV and not Android TV. But while taking a look at it, I found out that there is the AnymoteLibrary which exactly offers the kind of functionality I want. I downloaded it from here: https://github.com/google/googletv-android-samples
Where I am blocked at the moment:
So, I took the AnymoteLibrary from the link above and imported it to my existing project in Android Studio as a separate module. After some import fixes and Gradle cleans, I thought it might work. I adapted the build.gradle file which looks like this:
apply plugin: 'com.android.library'
dependencies {
//compile 'com.google.protobuf:protobuf-java:2.6.1'
compile files('libs/anymote.jar')
compile files('libs/bcprov-jdk15-143.jar')
compile files('libs/polo.jar')
compile files('libs/protobuf-java-2.2.0-lite.jar')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 17
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
and added and adapted the BlackJackRemoteActivity.java from the directory googletv-android-samples/BlackJackTVRemote/src/com/example/google/tv/remote/blackjack/ from the above link to my use case on the mobile module. With that I just wanted to test if I can get control the Android TV from my app and so I tried to run it. At first the app starts and it seems to work (See the following log messages) but then I get an exception:
E/KeyStoreUtil: Key store missing identity for anymote-remote
V/KeyStoreUtil: Generating key pair ...
V/KeyStoreUtil: Generating certificate ...
E/dalvikvm: Could not find class 'org.bouncycastle.jce.provider.BouncyCastleProvider', referenced from method com.google.polo.ssl.SslUtil.generateX509V1Certificate
W/dalvikvm: VFY: unable to resolve new-instance 9479 (Lorg/bouncycastle/jce/provider/BouncyCastleProvider;) in Lcom/google/polo/ssl/SslUtil;
E/dalvikvm: Could not find class 'org.bouncycastle.jce.provider.BouncyCastleProvider', referenced from method com.google.polo.ssl.SslUtil.generateX509V3Certificate
W/dalvikvm: VFY: unable to resolve new-instance 9479 (Lorg/bouncycastle/jce/provider/BouncyCastleProvider;) in Lcom/google/polo/ssl/SslUtil;
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x416a0e18)
The final exception message:
E/AndroidRuntime: FATAL EXCEPTION: main Process: androidtvportablecontroller, PID: 23592 java.lang.NoClassDefFoundError: org.bouncycastle.jce.provider.BouncyCastleProvider at com.google.polo.ssl.SslUtil.generateX509V3Certificate(SslUtil.java:118) at com.google.polo.ssl.SslUtil.generateX509V3Certificate(SslUtil.java:165) at com.example.google.tv.anymotelibrary.connection.KeyStoreManager.generateAppCertificate(KeyStoreManager.java:154)
I have absolutely no idea where the BouncyCastleProvider comes from and how I can adjust my code to fix this exception.
Again, I'm not even sure if I'm not wasting my time with this a bit older code from the Google TV days to get the functionality I need between the phone and TV app.
Help would be really appreciated.