Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am checking out backend for the first time in Android Studio, I'm following this video tutorial: https://cloud.google.com/mobile/

I added a backend module to my AS project with "App Engine Java Endpoints Module". The project shows no errors, can build and I tried syncing with gradle a few times.

However this keeps popping up:

App Engine Gradle configuration not detected on module, maybe you need to Sync Project with Gradle.

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:

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:

// 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
    }
}
like image 337
TomCB Avatar asked Nov 10 '22 22:11

TomCB


1 Answers

This strange issue happened in the auto created build.gradle file of the backend module.

I had move the "apply plugin" lines to the top to make it work and have the "backend" show up in the Run Configurations. 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." 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
  }
}
like image 98
sivag1 Avatar answered Nov 14 '22 22:11

sivag1