将Google云端点迁移到版本v2 [英] Migrating Google cloud endpoints to version v2
问题描述
我已经提到堆栈溢出的这个链接仍然无法迁移到版本v2。
建议在下面的链接我得到这个错误。
找不到google
这是我的项目级gradle文件
< pre $
buildscript {
repositories {
jcenter()
google()
}
依赖关系{
classpath'com.android.tools.build:gradle:3.0.0-alpha8'
classpathcom.google.cloud.tools:endpoints-framework -gradle-plugin:1.0.0
classpath'com.google.guava:guava:19.0'
//注意:不要在这里放置应用程序依赖关系;它们属于单个模块build.gradle文件中的
//
}
}
allprojects {
存储库{
jcenter()
google()
}
}
任务清理(类型:删除){
删除rootProject.buildDir
}
应用程序级别build.gradle
apply plugin:'com.android.application'
apply plugin:'com.google.cloud.tools.endpoints-framework-client'
android {
compileSdkVersion 26
buildToolsVersion26.0.1
defaultConfig {
applicationIdcom.xxx.migrationv2
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName1.0
testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner
}
buildTypes {
版本{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
配置{
compile.exclude组:org.apache.httpcomponents,模块:httpclient
}
依赖项{
implementation fileTree(dir:'libs',include: ['* .jar'])
implementation'com.android.support:appcompat-v7:26.0.0'
implementation'com.android.support.constraint:constraint-layout:1.0.2'
编译'com.google.code.findbugs:jsr305:2.0.1'
testImplementation'junit:junit:4.12'
androidTestImplementation'com.android.support.test:runner:1.0。 0'
androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.0'
endpointsServer项目(路径:':后端',配置:'端点')
编译'com.google.api-client:google-api-client:1.21.0'
}
后端build.gradle 请让我知道我在做什么错误在这个迁移任何建议将有帮助。
buildscript {
存储库{
jcenter()
}
依赖关系{
classpath'com.google.cloud.tools:appengine-gradle-plugin:+'
classpath'com.google.cloud.tools:endpoints-framework-gradle-plugin:+'
}
}
知识库{
jcenter();
}
apply plugin:'java'
apply plugin:'war'
apply plugin:'com.google.cloud.tools.appengine'
apply plugin:'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
// appengineSdk'com.google.appengine:appengine-java-sdk:1.9.42'
// compile'com.google.appengine:appengine-endpoints:1.9.42'
//编译'com.google.appengine:appengine-endpoints-deps:1.9.42'
//编译'javax.servlet:servlet-api:2.5'
编译组: 'com.google.endpoints',名称:'endpoints-framework',版本:'+'
编译'javax.inject:javax.inject:1'
}
endpointsServer {
// Endpoints Framework插件服务器端配置
hostname =xxx.appspot.com
}
// appengine {
/ / downloadSdk = true
// appcfg {
// oauth2 = true
//}
//端点{
// getClientLibsOnBuild = true
// getDiscoveryDocsOnBuild = true
//}
//
完整样本可在以下网址找到: https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating-android
替换为您的项目级别 build.gradle
,删除 google()
作为一个存储库:
build.gradle
buildscript {
存储库{
jcenter()
}
依赖关系{
classpath 'com.android.tools.build:gradle:2.3.3'
classpath'com.google.guava:guava:20.0'
//注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件
//
}
}
allprojects {
存储库{
mavenCentral()
jcenter()
}
}
您的应用级别 build.gradle
缺少 buildscript
。它需要看起来像这样。
app / build.gradle
buildscript {
存储库{
mavenCentral()
jcenter()
}
依赖关系{
//终结点框架Gradle插件
classpath'com.google.cloud.tools:endpoints-framework-gradle-plugin:+'
}
}
apply plugin:'com.android.application'
apply plugin:'com.google.cloud.tools.endpoints-framework-client'
android {
compileSdkVersion 26
buildToolsVersion '26 .0.1'
defaultConfig {
applicationId'com.example.migration.endpoints.app'
minSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName'1.0'
testInstrumentationRunner'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
依赖关系{
编译fileTree(dir:'libs',包括:['* .jar'])
// androidTestCompile编译使用Espresso编写的工具测试
//由Firebase测试实验室使用
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
exclude group:'com.android.support ',module:'support-annotations'
})
compile'com.android.support:appcompat-v7:26.+'
compile'com.android.support .constraint:constraint-layout:1.0.1'
compile'com.google.code.findbugs:jsr305:2.0.1'
testCompile'junit:junit:4.12'
// V2:端点Framework v2迁移
endpointsServer项目(路径:':backend',配置:'端点s')
compile'com.google.api-client:google-api-client:1.22.0'
compile'com.google.http-client:google-http-client-android:1.22 .0'
}
我的后端级别还有一些额外的依赖关系 build.gradle
基于: https://cloud.google.com/appengine/docs/standard/java/tools/gradle-endpoints-frameworks-plugin
< blockquote>
后端/ build.gradle
buildscript {
存储库{
jcenter()
}
依赖关系{
classpath'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0'
classpath'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'
}
}
知识库{
jcenter();
}
apply plugin:'java'
apply plugin:'war'
// V2:应用新的App Engine和Endpoints Framework服务器插件
apply plugin:'com.google.cloud.tools.appengine'
apply plugin:'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
依赖项{
// AppEngine
编译组:'com.google.appengine',名称:'appengine-api -1.0-sdk',版本:'+'
编译'javax.servlet:servlet-api:2.5'
// Cloud端点框架
providesCompile组:'javax。 servlet',名称:'servlet-api',版本:'2.5'
编译'jstl:jstl:1.2'
编译组:'javax.inject',名称:'javax.inject',版本:'1'
编译组:'com.google.endpoints',名称:'endpoints-framework',版本:'+'
编译组:'com.google .endpoints,名称:'endpoints-management-control-appengine',版本:'+'
编译组:'com.google.endpoints',名称:'endpoints-framework-auth',版本:'+ '
}
endpointsServer {
// Endpoints Framework插件服务器端配置
hostname =YOUR-PROJECT-ID.appspot.com
上面提供的这些并不是我所具有的直接表示,而是来自各种各样的组合和匹配Google文档来源。
I have referred this link on stack overflow still unable to migrate to version v2.
Link Referred from stack overflow
After doing changes as suggested in the below link i am getting this error.
Could not find method google() for arguments [] on repository container.
Here is my project level gradle file
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha8'
classpath "com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0"
classpath 'com.google.guava:guava:19.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.xxx.migrationv2"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.findbugs:jsr305:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
endpointsServer project(path: ':backend', configuration: 'endpoints')
compile 'com.google.api-client:google-api-client:1.21.0'
}
Backend build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:+'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
// appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
// compile 'com.google.appengine:appengine-endpoints:1.9.42'
// compile 'com.google.appengine:appengine-endpoints-deps:1.9.42'
// compile 'javax.servlet:servlet-api:2.5'
compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '+'
compile 'javax.inject:javax.inject:1'
}
endpointsServer {
// Endpoints Framework Plugin server-side configuration
hostname = "xxx.appspot.com"
}
//appengine {
// downloadSdk = true
// appcfg {
// oauth2 = true
// }
// endpoints {
// getClientLibsOnBuild = true
// getDiscoveryDocsOnBuild = true
// }
//}
Please let me know what am i doing wrong in this migration any suggestions will be helpful.
解决方案 Full samples are available on: https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating-android
Replace with your project level build.gradle
, removing google()
as a repository with this:
build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.guava:guava:20.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
}
}
Your app level build.gradle
is missing a buildscript
. It needs to look something like this.
app/build.gradle
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
// Endpoints Frameworks Gradle plugin
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId 'com.example.migration.endpoints.app'
minSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName '1.0'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// androidTestCompile compiles instrumentation tests written using Espresso
// used by Firebase Test Lab
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.google.code.findbugs:jsr305:2.0.1'
testCompile 'junit:junit:4.12'
// V2: Endpoints Framework v2 migration
endpointsServer project(path: ':backend', configuration: 'endpoints')
compile 'com.google.api-client:google-api-client:1.22.0'
compile 'com.google.http-client:google-http-client-android:1.22.0'
}
I also have some extra dependencies in my backend level build.gradle
based on: https://cloud.google.com/appengine/docs/standard/java/tools/gradle-endpoints-frameworks-plugin
backend/build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
// V2: Apply new App Engine and Endpoints Framework server plugins
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
// AppEngine
compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '+'
compile 'javax.servlet:servlet-api:2.5'
// Cloud Endpoints Framework
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
compile 'jstl:jstl:1.2'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '+'
compile group: 'com.google.endpoints', name: 'endpoints-management-control-appengine', version: '+'
compile group: 'com.google.endpoints', name: 'endpoints-framework-auth', version: '+'
}
endpointsServer {
// Endpoints Framework Plugin server-side configuration
hostname = "YOUR-PROJECT-ID.appspot.com"
}
These provided above are not direct representations of what I have, but are a mix and match from various Google documentation sources.
这篇关于将Google云端点迁移到版本v2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!