My project consists of an Android application and an Appengine Backend, I moved from eclipse to android studio and following some examples online as well as generating an appengine module from Android Studio I came up with this.
The android application's Gradle file
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
//compile project(':appcompat_v7_2')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile project(path: ':AgriExpenseTT-AppEngine', configuration: 'android-endpoints') //line that supposedly links the AppengineProject
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 20
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src', 'endpoint-libs/libdeviceinfoendpoint-v1/deviceinfoendpoint/deviceinfoendpoint-v1-generated-source', 'endpoint-libs/librpurchaseendpoint-v1/rpurchaseendpoint/rpurchaseendpoint-v1-generated-source', 'endpoint-libs/libupaccendpoint-v1/upaccendpoint/upaccendpoint-v1-generated-source', 'endpoint-libs/libcycleendpoint-v1/cycleendpoint/cycleendpoint-v1-generated-source', 'endpoint-libs/libtranslogendpoint-v1/translogendpoint/translogendpoint-v1-generated-source', 'endpoint-libs/libmessageEndpoint-v1/messageEndpoint/messageendpoint-v1-generated-source', 'endpoint-libs/libcycleuseendpoint-v1/cycleuseendpoint/cycleuseendpoint-v1-generated-source']
resources.srcDirs = ['src', 'endpoint-libs/libdeviceinfoendpoint-v1/deviceinfoendpoint/deviceinfoendpoint-v1-generated-source', 'endpoint-libs/librpurchaseendpoint-v1/rpurchaseendpoint/rpurchaseendpoint-v1-generated-source', 'endpoint-libs/libupaccendpoint-v1/upaccendpoint/upaccendpoint-v1-generated-source', 'endpoint-libs/libcycleendpoint-v1/cycleendpoint/cycleendpoint-v1-generated-source', 'endpoint-libs/libtranslogendpoint-v1/translogendpoint/translogendpoint-v1-generated-source', 'endpoint-libs/libmessageEndpoint-v1/messageEndpoint/messageendpoint-v1-generated-source', 'endpoint-libs/libcycleuseendpoint-v1/cycleuseendpoint/cycleuseendpoint-v1-generated-source']
aidl.srcDirs = ['src', 'endpoint-libs/libdeviceinfoendpoint-v1/deviceinfoendpoint/deviceinfoendpoint-v1-generated-source', 'endpoint-libs/librpurchaseendpoint-v1/rpurchaseendpoint/rpurchaseendpoint-v1-generated-source', 'endpoint-libs/libupaccendpoint-v1/upaccendpoint/upaccendpoint-v1-generated-source', 'endpoint-libs/libcycleendpoint-v1/cycleendpoint/cycleendpoint-v1-generated-source', 'endpoint-libs/libtranslogendpoint-v1/translogendpoint/translogendpoint-v1-generated-source', 'endpoint-libs/libmessageEndpoint-v1/messageEndpoint/messageendpoint-v1-generated-source', 'endpoint-libs/libcycleuseendpoint-v1/cycleuseendpoint/cycleuseendpoint-v1-generated-source']
renderscript.srcDirs = ['src', 'endpoint-libs/libdeviceinfoendpoint-v1/deviceinfoendpoint/deviceinfoendpoint-v1-generated-source', 'endpoint-libs/librpurchaseendpoint-v1/rpurchaseendpoint/rpurchaseendpoint-v1-generated-source', 'endpoint-libs/libupaccendpoint-v1/upaccendpoint/upaccendpoint-v1-generated-source', 'endpoint-libs/libcycleendpoint-v1/cycleendpoint/cycleendpoint-v1-generated-source', 'endpoint-libs/libtranslogendpoint-v1/translogendpoint/translogendpoint-v1-generated-source', 'endpoint-libs/libmessageEndpoint-v1/messageEndpoint/messageendpoint-v1-generated-source', 'endpoint-libs/libcycleuseendpoint-v1/cycleuseendpoint/cycleuseendpoint-v1-generated-source']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
The appengine's gradle file
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.google.appengine:appengine-endpoints:1.9.1'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.1'
compile 'javax.servlet:servlet-api:2.5'
compile 'org.datanucleus:datanucleus-core:3.2.8'
compile 'com.google.appengine.orm:datanucleus-appengine:2.1.2'
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'
}
repositories {
mavenCentral()
}
sourceSets {
main.java.srcDirs = ['src']
main.resources.srcDirs = ['src']
test.java.srcDirs = ['tests/java']
test.resources.srcDirs = ['tests/resources']
}
appengine { // ! ERROR IS HERE !
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
Error
Could not find method appengine() for arguments [build_8nkni14q2n6l61jnsyaantjd6$_run_closure4@188b4628] on project ':AgriExpenseTT-AppEngine'
Here you can find guide how to use App Engine with gradle: https://github.com/GoogleCloudPlatform/gradle-appengine-plugin
To use the App Engine plugin, include in your build script:
apply plugin: 'appengine'
The plugin JAR needs to be defined in the classpath of your build script. It is directly available on Maven Central. Alternatively, you can download it from GitHub and deploy it to your local repository. The following code snippet shows an example on how to retrieve it from Maven Central:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.17'
}
}
Note: The plugin requires you to set the environment variable APPENGINE_HOME or the system property appengine.sdk.root pointing to your current Google App Engine SDK installation. In case you have both variables set the system property takes precedence over the environment variable. Alternatively, you can choose to automatically download the SDK by setting the convention property downloadSdk to true. This option requires you to specify the SDK version you want to use by setting the configuration appengineSdk.
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.17'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With