Skip to content Skip to sidebar Skip to footer

Migrating Google Cloud Endpoints To Version V2

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

Solution 1:

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.


Solution 2:

You should not need the google() line in your repositories, which you currently have twice.


Post a Comment for "Migrating Google Cloud Endpoints To Version V2"