简体   繁体   English

无法在Android Studio中运行后端

[英]Cannot run backend in Android Studio

Update After some digging I found out that this is a bug. 更新 经过一番挖掘后,我发现这是一个错误。 It will be fixed in the following update of Android Studio: 1.0 RC3 它将在Android Studio的以下更新中修复:1.0 RC3

I am checking out backend for the first time in Android Studio, I'm following this video tutorial: https://cloud.google.com/mobile/ 我正在Android Studio中第一次检查后端,我正在关注此视频教程: https//cloud.google.com/mobile/

I added a backend module to my AS project with "App Engine Java Endpoints Module". 我使用“App Engine Java端点模块”向我的AS项目添加了一个后端模块。 The project shows no errors, can build and I tried syncing with gradle a few times. 该项目显示没有错误,可以构建,我尝试与gradle同步几次。

However this keeps popping up: 但是这种情况不断出现:

App Engine Gradle configuration not detected on module, maybe you need to Sync Project with Gradle. 在模块上未检测到App Engine Gradle配置,可能需要使用Gradle同步Project。

Could this be a bug or am I missing something? 这可能是一个错误还是我错过了什么?

Project level gradle: 项目级别:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0-rc1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

App gradle: 应用程序gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "be.thomascbeerten.cloudtest2"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.2'
    compile project(path: ':backend', configuration: 'android-endpoints')
}

backend gradle: 后端gradle:

// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin

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

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.14'
    compile 'com.google.appengine:appengine-endpoints:1.9.14'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.14'
    compile 'javax.servlet:servlet-api:2.5'
}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
    endpoints {
        getClientLibsOnBuild = true
        getDiscoveryDocsOnBuild = true
    }
}

This strange issue happened in the auto created build.gradle file of the backend module. 这个奇怪的问题发生在自动创建的后端模块的build.gradle文件中。

I had move the "apply plugin" lines to the top to make it work and have the "backend" show up in the Run Configurations. 我已将“apply plugin”行移到顶部以使其工作,并在运行配置中显示“后端”。 Default created file has the plugin lines somewhere in the middle. 默认创建的文件在中间的某处有插件行。

This will also avoid the "App Engine Gradle configuration not detected on module, maybe you need to Sync Project with Gradle." 这也将避免“在模块上未检测到App Engine Gradle配置,可能需要将项目与Gradle同步”。 error. 错误。

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

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

repositories {
    jcenter();
}

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

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

appengine {
  downloadSdk = true
  appcfg {
    oauth2 = true
  }
  endpoints {
    getClientLibsOnBuild = true
    getDiscoveryDocsOnBuild = true
  }
}

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

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