0

我已經參考了有關堆棧溢出的此鏈接,但仍然無法遷移到版本v2。將Google雲端點遷移到版本v2

Link Referred from stack overflow

在下面的鏈接我得到這個錯誤建議做更改之後。

Link Referred

找不到上儲存庫容器參數[]方法谷歌()。

這裏是我的項目級別gradle這個文件

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 
} 

應用級的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' 
} 

後端的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 
// } 
//} 

請讓我知道我在這個遷移中做錯了什麼,任何建議都會有所幫助。

回答

0

全部樣品可在:https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating-android

與您的項目水平build.gradle替換,刪除google()與此存儲庫:

的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() 
    } 
} 

您的應用程序級別build.gradle缺少buildscript。它需要看起來像這樣。

應用/的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' 
} 

我也有我的後端級別build.gradle一些額外的依賴基於:https://cloud.google.com/appengine/docs/standard/java/tools/gradle-endpoints-frameworks-plugin

後端/的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" 
} 

上面提供的這些內容不是我所具有的直接表示形式,而是來自各種Google文檔資源的混合搭配。

+0

非常感謝它在內部幫助我解決了gradle問題也解決了它。還有更多的問題是我們需要使用命令行部署未來部署? –

+0

在Android Studio中,您可以選擇右列中的Gradle選項卡,並且在您的後端任務下,您可以雙擊'appengineDeploy'來部署您的模塊。我現在就是這樣做的。 – gbhall

+0

如何上傳cron servelets,如果我使用端點進行部署,則會發出500內部服務器錯誤。有關cron servelets的任何想法? –

0

您不應該在您的存儲庫中需要google()行,該行目前有兩次。