【问题标题】:Why am I not able to use the DatastoreService class? App Engine SDK not installed correctly?为什么我无法使用 DatastoreService 类? App Engine SDK 未正确安装?
【发布时间】:2016-02-04 16:21:25
【问题描述】:

我在我的项目中添加了一个新的 AppEngine 模块,并且到目前为止它工作正常。 AppEngine 已安装,但我无法导入任何 com.google.* 包,所以我想,我做错了。我不知道是什么。

我当然可以使用所有 javax.servlet.http.* 的东西,但由于某种原因我不能使用 DatastoreService 类。

显然已经安装了 AppEngine,否则我将无法添加 AppEngine 模块,但似乎仍然缺少一些东西。

这是我的 build.gradle 文件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.31'
    compile 'javax.servlet:servlet-api:2.5'
}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }

【问题讨论】:

    标签: android google-app-engine android-studio android-gradle-plugin


    【解决方案1】:

    通过将 build.gradle 更改为此修复:

    buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.17'
        }
    }
    
    repositories {
        mavenCentral();
    }
    
    apply plugin: 'java'
    apply plugin: 'war'
    apply plugin: 'appengine'
    
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7
    
    dependencies {
        appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.17'
        compile 'com.google.appengine:appengine-endpoints:1.9.17'
        compile 'com.google.appengine:appengine-endpoints-deps:1.9.17'
        compile 'javax.servlet:servlet-api:2.5'
    }
    
    appengine {
        downloadSdk = true
        appcfg {
            oauth2 = true
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-24
      • 1970-01-01
      • 2021-07-24
      相关资源
      最近更新 更多