|
|
11 лет назад | |
|---|---|---|
| .. | ||
| GreeterGrpc.java | 11 лет назад | |
| Helloworld.java | 11 лет назад | |
| HelloworldActivity.java | 11 лет назад | |
| README.md | 11 лет назад | |
| activity_helloworld.xml | 11 лет назад | |
For this sample, we've already generated the server and client stubs from helloworld.proto.
Android Tutorial If you're new to Android development
We only have Android gRPC client in this example. Please follow examples in other languages to build and run a gRPC server.
Clone the gRPC Java git repo
$ git clone https://github.com/grpc/grpc-java
Install gRPC Java, as described in How to Build
$ # from this dir
$ cd grpc-java
$ # follow the instructions in 'How to Build'
Create an Android project under your working directory.
Set Application name to "Helloworld Example" and set Company Domain to "grpc.io". Make sure your package name is "io.grpc.helloworldexample"
Choose appropriate minimum SDK
Use Blank Activity
Set Activity Name to HelloworldActivity
Set Layout Name to activity_helloworld
Prepare the app
Clone this git repo
$ git clone https://github.com/grpc/grpc-common
In your AndroidManifest.xml, make sure you have
<uses-permission android:name="android.permission.INTERNET" />
added outside your appplication tag
Copy or download other dependencies to your_app_dir/app/libs/:
protobuf nano:
$ cp ~/.m2/repository/com/google/protobuf/nano/protobuf-javanano/2.6.2-pre/protobuf-javanano-2.6.2-pre.jar your_app_dir/app/libs/
Make sure your_app_dir/app/build.gradle contains:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}