i want use grpc in android studio, failed in gradle setting.
my gradle plugin version 2.1.2. have installed gradle 2.14.
in app\build.gradle file:
apply plugin: 'com.android.application' android { compilesdkversion 23 buildtoolsversion "23.0.3" apply plugin: "com.google.protobuf" defaultconfig { applicationid "com.example.test.test_20" minsdkversion 15 targetsdkversion 23 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } debug { debuggable true jnidebuggable true } } buildscript { repositories { maven { mavencentral() } } dependencies { classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0" } } protobuf { protoc { // version of protoc must match protobuf-java. if don't depend on // protobuf-java directly, transitively depending on // protobuf-java version grpc depends on. artifact = "com.google.protobuf:protoc:3.0.0" } plugins { grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.0.0' } } generateprototasks { all()*.plugins { grpc {} } } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'io.grpc:grpc-okhttp:1.0.0' compile 'io.grpc:grpc-protobuf-lite:1.0.0' compile 'io.grpc:grpc-stub:1.0.0' }
gradle sync message output error:(7, 0) plugin id 'com.google.protobuf' not found.
what wrong in setting?
i create new empty project, , app/build.gradle file:
apply plugin: 'com.android.application' apply plugin: "com.google.protobuf" buildscript { repositories { maven { //mavencentral() url 'https://repo1.maven.org/maven2' } } dependencies { classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0" } } android { compilesdkversion 23 buildtoolsversion "23.0.3" defaultconfig { applicationid "com.example.test.testprotobuf" minsdkversion 15 targetsdkversion 23 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) testcompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' }
and gradle-wrapper.properties file:
distributionbase=gradle_user_home distributionpath=wrapper/dists zipstorebase=gradle_user_home zipstorepath=wrapper/dists distributionurl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
i excute "gradlew build" command successfully. , sync gradle, prompt “error:(2, 0) cause: org/gradle/api/internal/file/collections/defaultdirectoryfiletreefactory ” 。
something wrong in build.gradle. have move parts:
apply plugin: 'com.android.application' apply plugin: "com.google.protobuf" buildscript { repositories { maven { mavencentral() } } dependencies { classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0" } } android { }
Comments
Post a Comment