简体   繁体   English

Google App Engine在Hello World应用程序中不起作用

[英]Google App Engine is not working in Hello World app

As the name of the post implies, I cannot get a basic Hello World Android app to deploy after modifying my Gradle build scripts to include the Google App Engine. 就像帖子的名称所暗示的那样,在修改Gradle构建脚本以使其包含Google App Engine之后,我无法部署基本的Hello World Android应用。 Here is my app's build.gradle file: 这是我的应用程序的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.tbiegeleisen.myfirstapp"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        debug {
            debuggable true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.13'
}

And here is my project's build.gradle file: 这是我项目的build.gradle文件:

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

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.13'
    }
}

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.13'
    compile "javax.servlet:servlet-api:3.0"
    compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.13'
}

repositories {
    mavenCentral();
}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

I am fairly certain that the script is working on some level, because the first time it ran it took a really long time. 我相当确定该脚本在某种程度上可以正常工作,因为它第一次运行需要很长时间。 During this first time, the plugin was being downloaded. 在这第一次期间,正在下载插件。 When I comment out all of the Google App Engine stuff, then the Hello World app launches with no problems. 当我注释掉所有 Google App Engine内容时,Hello World应用程序启动就没有问题了。 I have the feeling that Android Studio is trying execute the plugin, but either a dependency is missing, or I have a configuration problem. 我感觉Android Studio正在尝试执行插件,但是缺少依赖项,或者我遇到配置问题。

When I run the app, Android Studio will spin for around 5-10 minutes, and the die with this error message: 当我运行该应用程序时,Android Studio会旋转约5-10分钟,并且死于此错误消息:

Execution failed for task ':app:preDexDebug'.
\> com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Program
Files\Java\jdk.1.7.0_80\bin\java.exe'' finished with non-zero exit value 3

I don't know whether this error output will be useful, but I am including it anyway. 我不知道此错误输出是否有用,但是无论如何我都将其包括在内。

My hope is that an Android guru on Stack Overflow will be able to help me with this problem. 我希望在Stack Overflow上使用Android的专家能够解决这个问题。 For reference, I need the App Engine because I plan on using geocoding at a later time. 作为参考,我需要App Engine,因为我计划在以后使用地理编码。 I have already been stuck on this for several days now, and I have tried every resource I could find through Google and Stack Overflow. 我已经在此问题上停留了几天,并且尝试了所有可以通过Google和Stack Overflow找到的资源。

I think it has something to do with your dependencies. 我认为这与您的依赖关系有关。 According to Google App Engine documentation, the supported version of Java servlets is 2.5. 根据Google App Engine文档,受支持的Java Servlet版本为2.5。 I don't think Google App Engine supports version 3.0 yet. 我认为Google App Engine还不支持3.0版。

Quoting from Google App Engine Java documentation: 引用Google App Engine Java文档:

App Engine uses the Java Servlet 2.5 standard for web applications. App Engine将Java Servlet 2.5标准用于Web应用程序。 You provide your app's servlet classes, JavaServer Pages (JSPs), static files and data files, along with the deployment descriptor (the web.xml file) and other configuration files, in a standard WAR directory structure. 您可以在标准WAR目录结构中提供应用程序的servlet类,JavaServer Pages(JSP),静态文件和数据文件,以及部署描述符(web.xml文件)和其他配置文件。 App Engine serves requests by invoking servlets according to the deployment descriptor. App Engine通过根据部署描述符调用servlet来处理请求。

You have to change your dependency to this: 您必须更改对此的依赖性:

compile "javax.servlet:servlet-api:2.5"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM