【问题标题】:Cannot run backend in Android Studio无法在 Android Studio 中运行后端
【发布时间】:2014-11-29 08:31:35
【问题描述】:

更新 经过一番挖掘,我发现这是一个错误。它将在 Android Studio 的以下更新中修复:1.0 RC3

我第一次在 Android Studio 中检查后端,我正在关注这个视频教程: https://cloud.google.com/mobile/

我使用“App Engine Java Endpoints Module”向我的 AS 项目添加了一个后端模块。 该项目显示没有错误,可以构建,我尝试与 gradle 同步几次。

但是这不断弹出:

模块上未检测到 App Engine Gradle 配置,您可能需要将项目与 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()
    }
}

应用分级:

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')
}

后端分级:

// 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
    }
}

【问题讨论】:

  • 我设法通过命令行使用 gradle 构建和启动后端,并通过“gradle appengineRun”启动它。确保您使用的是 Java 7。
  • 我在 android studio 1.1.0 中的端点运行配置有同样的问题。我用你的建议“gradle appengineRun”解决了它

标签: android android-studio cloud endpoint


【解决方案1】:

这个奇怪的问题发生在后端模块的自动创建的 build.gradle 文件中。

我已将“应用插件”行移至顶部以使其正常工作,并在“运行配置”中显示“后端”。默认创建的文件在中间某处有插件行。

这也将避免“未在模块上检测到 App Engine Gradle 配置,也许您需要将项目与 Gradle 同步”。错误。

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
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-13
    • 2013-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 1970-01-01
    • 2022-12-17
    相关资源
    最近更新 更多