googlecodelabs/androidthings-googleassistant

Compile error (lots of 'cannot find symbol' and 'package does not exist')

Closed this issue · 5 comments

On a fresh download of the repo, opening in Android Studio and pressing build, I got a lot of errors, seemingly of missing dependencies.

Executing tasks: [:step1-start-here:assembleDebug]
<snip...>
:step1-start-here:compileDebugJavaWithJavac
/Users/joerick/Downloads/androidthings-googleassistant-master/step1-start-here/src/main/java/com/example/androidthings/assistant/AssistantActivity.java:36: error: cannot find symbol
import com.google.android.things.contrib.driver.button.Button;
^
symbol: class Button
location: package com.google.android.things.contrib.driver.button
/Users/joerick/Downloads/androidthings-googleassistant-master/step1-start-here/src/main/java/com/example/androidthings/assistant/AssistantActivity.java:45: error: cannot find symbol
import com.google.protobuf.ByteString;
^
symbol: class ByteString
location: package com.google.protobuf
/Users/joerick/Downloads/androidthings-googleassistant-master/step1-start-here/src/main/java/com/example/androidthings/assistant/AssistantActivity.java:46: error: package io.grpc does not exist
import io.grpc.ManagedChannel;
^

etc....

Full log here

It appears the build is not finding dependencies declared in the :shared build.gradle. Indeed, my current workaround is to paste the :shared dependencies into step's build.gradle dependencies section.

e.g. step1-start-here/build.gradle

...

dependencies {
    compileOnly 'com.google.android.things:androidthings:0.6-devpreview'
    implementation 'com.google.android.things.contrib:driver-button:0.4'

    implementation 'io.grpc:grpc-okhttp:1.2.0'
    implementation 'io.grpc:grpc-protobuf-lite:1.2.0'
    implementation 'io.grpc:grpc-stub:1.2.0'
    implementation 'io.grpc:grpc-auth:1.2.0'

    implementation 'javax.annotation:javax.annotation-api:1.2'

    implementation('com.google.auth:google-auth-library-oauth2-http:0.6.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    implementation project(':shared')
    compileOnly 'com.google.android.things:androidthings:0.6-devpreview'
}

Any idea why my project isn't finding the shared dependencies by default?

Same. I think this is oldish gradle syntax but this is my first use of gradle. Changing "implementation" to "api" in :shared seems to have the same effect as moving the "implementation"s to :step1-start-here.

Still having trouble with missing raw() methods on generated classes.

@treyhyde ah, that sounds like a better solution. so api in shared means that dependencies are exposed, not hidden.

I can do a PR to that effect if useful @Fleker ?

I'm not seeing any missing raw() methods though @treyhyde . Might be worth raising a separate issue with a full log of that one.

Hey, I think using api instead of implementation is the right way to pass through dependencies. I have already submitted a change internally, so I'll push out the change today.

Okay the changes are on GitHub now.