It's probably not a good idea to try to include your server and Android app
in the same project; at the least, you should not be trying to run a gRPC
server via Android Studio. You need your server to depend on grpc-netty,
and this is not intended/supported for Android.

I would suggest creating two projects, one for Android, one for your
server, and just copy and modify the existing examples to create each
project. If you want to share the same .proto definitions between the
projects, just put the protos in a separate project that the other two
depend on.

Hope this helps.

Eric

On Tue, Jul 18, 2017 at 9:57 PM, <[email protected]> wrote:

> Yes, the example project builds perfectly. But as soon as I copy settings
> over to my projects, things start to break.
>
> I'm new to Android, Gradle, and gRPC, so it's too easy for me to miss
> anything.. Sorry to borther.
>
> From a beginner's point of view, the example project is too complicated
> and is not only "hello world". It's like a sub project in gRPC project and
> contains advanced examples, so I'm not sure which settings/codes are
> essential to the simplest helloworld demo, and it  isn't organized in
> Android Studio‘s way.. It's just my two cents.
>
> I use Android Studio and my project structure is this, I have an Android
>  module named as Client, and a Java module named as Protocol.  Protocol
> module contains proto files and generates necessary gRPC classes. Client
> module references Protocol, and in the future when I create a Server
> module, it could also reference Protocol module..
>
> I committed the project to GitHub. I would so appreciate if you could
> clone my *debug *branch and take a look.
>
> git clone -b debug https://github.com/gqqnbig/SimpleChat2017
>
> 在 2017年7月18日星期二 UTC-7下午1:48:09,Eric Gribkoff写道:
>>
>> You still need the javalite {} block in both protobuf.plugins and
>> protobuf.generateProtoTasks. I would suggest following these instructions
>> <https://grpc.io/docs/quickstart/android.html> to build the example gRPC
>> Android Hello World app (here is its build.gradle
>> <https://github.com/grpc/grpc-java/blob/master/examples/android/helloworld/app/build.gradle>),
>> confirm the example builds in your local environment then adapt the working
>> example to your project. If the Hello World app doesn't build for you, let
>> me know.
>>
>> Best,
>>
>> Eric
>>
>> On Sun, Jul 16, 2017 at 3:51 PM, <[email protected]> wrote:
>>
>>> I now have another problem. Do you midn looking again?
>>>
>>> I make the project, but Android Studio cannot find many packages.. See
>>> the screenshot.
>>>
>>>
>>> <https://lh3.googleusercontent.com/-DUa5PYj90tM/WWvtsVqAb0I/AAAAAAAAIMo/8VGCP-DjAK0eJeizNioNCKOrrbZy3VoDQCLcBGAs/s1600/Capture.JPG>
>>>
>>>
>>>
>>> I already have
>>>
>>>
>>> dependencies {
>>>     compile 'io.grpc:grpc-okhttp:1.4.0'
>>>     compile 'io.grpc:grpc-protobuf-lite:1.4.0'
>>>     compile 'io.grpc:grpc-stub:1.4.0'
>>>     compile 'javax.annotation:javax.annotation-api:1.2'
>>> }
>>>
>>>
>>> in build.gradle.
>>>
>>>
>>> Am I still missing anything?
>>>
>>>
>>> 在 2017年7月16日星期日 UTC-7上午11:40:01,Eric Gribkoff写道:
>>>>
>>>> Can you try "./gradlew clean" and then rebuild? You can encounter this
>>>> type of error when you've already built a project using one flavor of
>>>> protobuf, then switch to another. The generated files from the old proto
>>>> flavor are not always removed automatically, causing conflicts, but
>>>> "./gradlew clean" will clear them out.
>>>>
>>>> Thanks,
>>>>
>>>> Eric
>>>>
>>>> On Sat, Jul 15, 2017 at 11:21 PM, <[email protected]> wrote:
>>>>
>>>>> This is my build.gradle.
>>>>>
>>>>> apply plugin: 'java'
>>>>>
>>>>> dependencies {
>>>>>     compile fileTree(dir: 'libs', include: ['*.jar'])
>>>>>
>>>>>     compile 'io.grpc:grpc-okhttp:1.4.0'
>>>>>     compile 'io.grpc:grpc-protobuf-lite:1.4.0'
>>>>>     compile 'io.grpc:grpc-stub:1.4.0'
>>>>>     compile 'javax.annotation:javax.annotation-api:1.2'
>>>>> }
>>>>>
>>>>> sourceCompatibility = "1.7"
>>>>> targetCompatibility = "1.7"
>>>>>
>>>>>
>>>>> apply plugin: 'com.google.protobuf'
>>>>>
>>>>> protobuf {
>>>>>     protoc {
>>>>>         artifact = 'com.google.protobuf:protoc:3.0.0'
>>>>>     }
>>>>>     plugins {
>>>>>         javalite {
>>>>>             artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
>>>>>         }
>>>>>         grpc {
>>>>>             artifact = 'io.grpc:protoc-gen-grpc-java:1.0.0' // 
>>>>> CURRENT_GRPC_VERSION
>>>>>         }
>>>>>     }
>>>>>     generateProtoTasks {
>>>>>         all().each { task ->
>>>>>             task.plugins {
>>>>>                 javalite {}
>>>>>                 grpc {
>>>>>                     // Options added to --grpc_out
>>>>>                     option 'lite'
>>>>>                 }
>>>>>             }
>>>>>         }
>>>>>     }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> I copied hellowworld.proto to my module. Once I make the module, Android 
>>>>> Studio gives error Duplicated class 
>>>>> io.grpc.examples.helloworld.HelloReply. I searched the file explorer, the 
>>>>> same class exists in 
>>>>> build\generated\source\proto\main\java\io\grpc\examples\helloworld\HelloReply.java
>>>>>  and 
>>>>> D:\SimpleChat\protocol\build\generated\source\proto\main\javalite\io\grpc\examples\helloworld\HelloReply.java.
>>>>>
>>>>>
>>>>>
>>>>> <https://lh3.googleusercontent.com/-uSl8ji65z40/WWsF86qV1fI/AAAAAAAAIMc/3jlf8CfyW-EOze4XmNUZhH1lZAPR8JfRgCLcBGAs/s1600/%25E6%258D%2595%25E8%258E%25B7.JPG>
>>>>>
>>>>>
>>>>>
>>>>> I checked the sample repository in https://github.com/grpc/grpc-java, it 
>>>>> only has the java one.
>>>>>
>>>>>
>>>>> How do I resolve this?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "grpc.io" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at https://groups.google.com/group/grpc-io.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/grpc-io/2071b2d9-9168-4b20
>>>>> -83ec-769215328a83%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/grpc-io/2071b2d9-9168-4b20-83ec-769215328a83%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "grpc.io" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/grpc-io.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/grpc-io/8c810d1e-727e-4df0-a046-431fde8f3ee9%40googlegroups.com
>>> <https://groups.google.com/d/msgid/grpc-io/8c810d1e-727e-4df0-a046-431fde8f3ee9%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/grpc-io/a7429221-22be-4dbf-b81b-6fd5c4c4aa97%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/a7429221-22be-4dbf-b81b-6fd5c4c4aa97%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CALUXJ7jQX3TpM5O0HFLvc1fv1A0pJ-eYP5kWWBySJLn0D5WasQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to