Cannot properly compile play services for libgdx - android-studio

So I've been trying to add google play services for my game.
First thing I did was add the dependency to the gradle file. This is how it looks now:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "My First Game"
gdxVersion = '1.9.3'
roboVMVersion = '2.1.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
googlePlayVersion = '9.4.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
compile "com.google.android.gms:play-services:$googlePlayVersion"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
}
}
tasks.eclipse.doLast {
delete ".project"
}
Here is a picture of the packages I have installed
However I still can't use the library and if I try to make for example an AdView (which I should now be able to) it goes red and can't be identified, however I can Alt+Enter to
Add library 'play-services-ads-lite-9.4.0' to classpath
If I add that, it adds the following line to the module (not project) gradle file:
compile 'com.google.android.gms:play-services-ads-lite:9.4.0'
and I get this gradle error.
If I go to:
/home/user/Android/Sdk/extras/google/m2repository/com/google/android
I can see the folders play-services, play-services-ads, etc, so I know they are there!
Thank you for taking the time to look into my problem. All help is appreciated!
EDIT: It has come to my attention that you might need the code: apply plugin: 'com.google.gms.google-services'.
I'm not sure where this should be however it says i need a file google-services.json. Not sure you should need this? Here is where i place the above line of code:
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
compile "com.google.android.gms:play-services:$googlePlayVersion"
}
apply plugin: 'com.google.gms.google-services'
}
EDIT2: if I try to put the dependency as well as the "apply plugin" in this file instead of the project gradle I get the same result in the fork of an error message saying that google-services.json is missing. This is my module android gradle:
android {
buildToolsVersion "23.0.2"
compileSdkVersion 23
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
instrumentTest.setRoot('tests')
}
defaultConfig {
applicationId "com.oscarboking.myfirstgame"
minSdkVersion 9
targetSdkVersion 23
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.oscarboking.myfirstgame/AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}
jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
classpath {
plusConfigurations += [project.configurations.compile]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}
project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [COMPILE: [plus: [project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
}
}
}
}
}
}
}
dependencies {
compile "com.google.android.gms:play-services:9.4.0"
}
apply plugin: 'com.google.gms.google-services'
If I try to use anything in the library I can alt+enter to the dependency however it tries to add it to the core module gradle file.

I'm using classpath 'com.google.gms:google-services:2.0.0' in my project gradle and compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-appinvite:8.4.0'
compile 'com.google.android.gms:play-services-games:8.4.0' in my android module gradle.
I'm also using google analytics, so the first one or two imports may be unnecessary.
Maybe you have to clean the project/remove the .gradle folder.

Related

Autocompletion not working in Android Studio Arctic Fox inside buildSrc

I am writing a custom plugin inside buildSrc using Android Studio Arctic Fox installed by brew. After some tests, there is a problem with the autocompletion of imports. It works inside app/build.gradle.kts that I can do import com.android.build.api.dsl.*, but inside buildSrc this raised Unresolved reference on android namespace.
The root build.gradle.kts:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
extra["kotlin_version"] = "1.4.32"
classpath("com.android.tools.build:gradle:7.0.2")
classpath(kotlin("gradle-plugin", version = "1.4.32"))
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
build.gradle.kts under buildSrc:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.4.31"
`kotlin-dsl`
}
repositories {
google()
mavenCentral()
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "11"
apiVersion = "1.4"
}
}
dependencies {
implementation("com.android.tools.build:gradle:7.0.2")
implementation("com.android.tools.build:gradle-api:7.0.2")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32")
implementation(kotlin("stdlib"))
gradleApi()
}
build.gradle.kts under app:
import com.example.pythonLibs
plugins {
id("com.android.application")
kotlin("android")
id("com.example.plugin")
}
android {
compileSdk = 30
ndkVersion = "23.0.7599858"
sourceSets {
getByName("main") {
pythonLibs {
srcDir("src/main/pythonLibs")
}
}
}
defaultConfig {
applicationId = "com.example.embedpythontest"
minSdk = 23
targetSdk = 30
versionCode = 1
versionName = "1.0.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// consumerProguardFiles = [file("consumer-rules.pro")]
externalNativeBuild {
cmake {
//arguments("-DANDROID_STL=c++_shared")
//cppFlags("")
}
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
version = "3.21.3"
}
}
compileOptions {
sourceCompatibility(JavaVersion.VERSION_11)
targetCompatibility(JavaVersion.VERSION_11)
}
kotlinOptions {
jvmTarget = "11"
apiVersion = "1.4"
}
}
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation("androidx.appcompat:appcompat:1.3.1")
implementation("com.google.android.material:material:1.4.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
}
in all files under buildSrc/src/main/kotlin/**, when doing import com.android.build.api.dsl.*, a problem shown but build project is ok. But if I do import inside buildSrc/build.gradle.kts, it won't be compiled. But the same thing could be done inside app/build.gradle.kts.
Why Android Studio cannot find the class?
This problem is caused by not being familiar with the dependencies in Gradle. After changing the dependncy block to:
dependencies {
implementation("com.android.tools.build:gradle-api:7.0.2")
implementation(kotlin("stdlib"))
gradleApi()
}
which copied from here that would solve the problem.

Android Studio Wikitude Native SDK Issue

So im trying to first build a basic app using android studio and Wikitudes Native SDK to make an AR app. After following the setup instructions ive ran into an error I cant seem to solve but have an idea of why/where its happening. Does anyone know what could be causing these errors?
This image here shows the errors I am getting and what looks to be an issue with a few of the imports
Here is also a copy of my build.gradle file (Module: app), and my build.gradle file (Module: NativeSDKExamples), respectively:
apply plugin: 'com.android.application'
android {
compileSdkVersion commonCompileSdkVersion
buildToolsVersion commonBuildToolsVersion
defaultConfig {
applicationId "com.uhg.ent.mobile.lifesciences.amplify"
minSdkVersion commonMinSdkVersion
targetSdkVersion commonTargetSdkVersion
versionCode 1
versionName "7.2.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable true
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "app-" + variant.buildType.name + ".apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
flavorDimensions "arch"
productFlavors {
arm7 {
dimension "arch"
}
arm8 {
dimension "arch"
}
x86 {
dimension "arch"
}
allarchs {
dimension "arch"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile (name: 'wikitude-native-sdk', ext:'aar')
arm7Compile project(path: ':plugins', configuration: 'arm7Release')
arm8Compile project(path: ':plugins', configuration: 'arm8Release')
x86Compile project(path: ':plugins', configuration: 'x86Release')
allarchsCompile project(path: ':plugins', configuration: 'allarchsRelease')
compile "com.android.support:appcompat-v7:$commonSupportLibVersion"
compile "com.android.support:design:$commonSupportLibVersion"
compile "com.android.support:support-v4:$commonSupportLibVersion"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android:flexbox:0.2.5'
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
AND
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
subprojects {
ext.commonCompileSdkVersion = 26
ext.commonBuildToolsVersion = "26.0.0"
ext.commonMinSdkVersion = 19
ext.commonTargetSdkVersion = 26
ext.commonSupportLibVersion = "26.0.0"
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}

Facing issues while running cucumber with serenity

To integrate Cucumber with Serenity, I have created below Gardle file. Serenity is working fine, however I am not able to use it with Cucumber. When I use #RunWith(CucumberWithSerenity.class) in runner class, it gives me unresolved type error.
build.gradle:
apply plugin: "java"
apply plugin: "maven"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'
apply plugin: 'com.jfrog.bintray'
group = "myorg"
version = 1.0
repositories {
maven {
url "http://nexus2.sdmc.ao-srv.com/content/groups/inhouse_dit/"
}
}
buildscript {
repositories {
maven {
url "http://nexus2.sdmc.ao-srv.com/content/groups/inhouse_dit/"
}
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:1.0.47")
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6'
}
}
ext {
bintrayBaseUrl = 'https://api.bintray.com/maven'
bintrayRepository = 'maven'
bintrayPackage = 'serenity-cucumber'
projectDescription = 'Serenity Cucumber integration'
if (!project.hasProperty("bintrayUsername")) {
bintrayUsername = 'wakaleo'
}
if (!project.hasProperty("bintrayApiKey")) {
bintrayApiKey = ''
}
serenityCoreVersion = '1.0.49'
cucumberJVMVersion = '1.2.2'
//versionCounter = new ProjectVersionCounter(isRelease: project.hasProperty("releaseBuild"))
}
sourceSets.all { set ->
def jarTask = task("${set.name}Jar", type: Jar) {
baseName = baseName + "-$set.name"
from set.output
}
artifacts {
archives jarTask
}
}
sourceSets {
api
impl
}
dependencies {
apiCompile 'commons-codec:commons-codec:1.5'
implCompile sourceSets.api.output
implCompile 'commons-lang:commons-lang:2.6'
compile "info.cukes:cucumber-java:${cucumberJVMVersion}"
compile "info.cukes:cucumber-junit:${cucumberJVMVersion}"
testCompile 'net.serenity-bdd:core:1.0.47'
testCompile 'net.serenity-bdd:serenity-junit:1.0.47'
testCompile('junit:junit:4.11')
testCompile('org.assertj:assertj-core:1.7.0')
testCompile('org.slf4j:slf4j-simple:1.7.7')
testCompile sourceSets.api.output
testCompile sourceSets.impl.output
testCompile 'org.codehaus.groovy:groovy-all:2.3.6'
testCompile("org.spockframework:spock-core:0.7-groovy-2.0") {
exclude group: "junit"
exclude module: "groovy-all"
}
testCompile("com.github.goldin:spock-extensions:0.1.4") {
exclude module: "spock-core"
exclude module: "slf4j-api"
}
runtime configurations.apiRuntime
runtime configurations.implRuntime
}
gradle.startParameter.continueOnFailure = true
jar {
from sourceSets.api.output
from sourceSets.impl.output
manifest {
attributes("Implementation-Title": "Serenity Cucumber Plugin",
"Implementation-Version": project.version.toString())
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar, javadocJar
}
bintray {
user = bintrayUsername //this usually comes form gradle.properties file in ~/.gradle
key = bintrayApiKey //this usually comes form gradle.properties file in ~/.gradle
publications = ['mavenJava'] // see publications closure
pkg {
repo = 'maven'
userOrg = 'serenity'
name = 'serenity-cucumber'
desc = 'Serenity Cucumber integration'
licenses = ['Apache-2.0']
labels = ['serenity','bdd','cucumber']
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri("${buildDir}/repo"))
addFilter("main") { artifact, file -> artifact.name == project.name }
["api", "impl"].each { type ->
addFilter(type) { artifact, file -> artifact.name.endsWith("-$type") }
// We now have to map our configurations to the correct maven scope for each pom
["compile", "runtime"].each { scope ->
configuration = configurations[type + scope.capitalize()]
["main", type].each { pomName ->
pom(pomName).scopeMappings.addMapping 1, configuration, scope
}
}
}
}
}
}
task wrapper (type: Wrapper) {
gradleVersion = '2.3'
distributionUrl = 'http://nexus2.sdmc.ao-srv.com/content/repositories/inhouse_dit_thirdparty/org/gradle/gradle-bin/2.3/gradle-2.3-bin.zip'
}
Please suggest what I need to change to run serenity with Cucumber. Thanks in advance.
You need to add serenity-cucumber to your dependencies:
testCompile 'net.serenity-bdd:serenity-cucumber:1.0.17'
Following line fixed the issue for me (gradle 4.10):
testCompile group: 'net.serenity-bdd', name: 'serenity-cucumber', version: '1.9.40'

Robotium in Android Studio with Cucumber

I have been trying to integrate Cucumber(java) with Robotium to add BDD to android tests in the Android studio. Unfortunately i am getting stuck trying to run the Cucumber features as it is not able to identify the step definitions.
My folder structure is as below:
ParentProject
|
Module
|
src
|
instrumentTest
|
java(this is the source root in build.gradle)
|
cucumbertests
|
CukeRunner.java
|
steps
|
resources
|
cucumbertests
|
Sample.feature
The above setup works fine in intellij.
My build.gradle in the module is as follows:
buildscript {
dependencies {
repositories {
mavenCentral()
mavenLocal()
}
classpath 'com.android.tools.build:gradle:0.7.3'
}
}
apply plugin: 'android'
dependencies {
repositories {
mavenCentral()
mavenLocal()
}
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:appcompat-v7:19.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.dagger:dagger:1.1.0'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.squareup.okhttp:okhttp:1.2.1'
compile 'com.squareup.retrofit:retrofit:1.2.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.guava:guava:15.0'
compile 'com.google.maps.android:android-maps-utils:0.2.1'
compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
compile fileTree(dir: 'libs', include: '*.jar')
instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3.1'
instrumentTestCompile 'info.cukes:cucumber-android:1.1.5'
instrumentTestCompile 'info.cukes:cucumber-junit:1.1.5'
instrumentTestCompile 'info.cukes:cucumber-picocontainer:1.1.5'
instrumentTestCompile 'info.cukes:gherkin:2.12.2'
}
android {
testBuildType "debug"
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
signingConfigs {
debug {
storeFile file('../certificate/debug.keystore')
}
}
sourceSets {
instrumentTest {
java.srcDirs = ['src/instrumentTest/java','src/instrumentTest/cucumber']
}
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'AndroidRSS/src']
resources.srcDirs = ['src/main/res']
aidl.srcDirs = ['src/main/aidl']
renderscript.srcDirs = ['src/main/rs']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
}
}
Error i get is that Cucumber hasnt been able to detect the step definitions. Since this structure works in intellij i think it may just be different way to be able to have this working in Android studio.
I am trying to have a test work like this https://stackoverflow.com/a/19940625/1165859
My feature file is :
The Feature file run config is :
The cukerunner is
package cucumbertests;
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#Cucumber.Options()
public class cukerunner {
}
Run results i get are:
Inspite of these methods implemented in the cucumbertests.steps
It seems gradle tags are misplaced in build.gradle script file . Please look at below build.gradle file and do the necessary changes.
buildscript {
repositories {
mavenCentral() // This only tells gradle where the to find the android plugin
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.3'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:appcompat-v7:19.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.dagger:dagger:1.1.0'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.squareup.okhttp:okhttp:1.2.1'
compile 'com.squareup.retrofit:retrofit:1.2.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.guava:guava:15.0'
compile 'com.google.maps.android:android-maps-utils:0.2.1'
compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
compile fileTree(dir: 'libs', include: '*.jar')
instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3.1'
instrumentTestCompile 'info.cukes:cucumber-android:1.1.5'
instrumentTestCompile 'info.cukes:cucumber-junit:1.1.5'
instrumentTestCompile 'info.cukes:cucumber-picocontainer:1.1.5'
instrumentTestCompile 'info.cukes:gherkin:2.12.2'
}
android {
testBuildType "debug"
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
signingConfigs {
debug {
storeFile file('../certificate/debug.keystore')
}
}
sourceSets {
instrumentTest {
java.srcDirs = ['src/instrumentTest/java','src/instrumentTest/cucumber']
}
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'AndroidRSS/src']
resources.srcDirs = ['src/main/res']
aidl.srcDirs = ['src/main/aidl']
renderscript.srcDirs = ['src/main/rs']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
}
}
What is there inside src/instrumentTest/cucumber directory. If you have any java classes there I think you have to move then in java directory of test project.
On cucumber github page there's a new implementation of how to use cucumber on Android Studio.
I've tested today and it worked
Check it out: https://github.com/cucumber/cucumber-jvm/tree/master/examples/android/android-studio/Cukeulator
I'll be glad to help if you have any doubts

Compile error during compilation with javac | Groovy

Have an err with compiling gradle idea
error see on screen
http://upwap.ru/1884422
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'code-quality'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'project-reports'
sourceCompatibility = 1.6 archivesBaseName = 'opas-client'
ideaModule { downloadJavadoc = true }
buildscript {
repositories {
mavenRepo urls: "f:/dev/lib/"
}
}
version = '0.1'
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(':release')) {
version = '0.1.2' // } else { // version = '1.0.624'
}
}
repositories {
mavenRepo urls: "f:/dev/lib/"
}
dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.7.5'
compile 'log4j:log4j:1.2.14',
'com.caucho:hessian:4.0.7',
'com.toedter:jcalendar:1.3.2',
'org.springframework:spring-context-support:3.0.5.RELEASE',
'org.springframework:spring-web:3.0.5.RELEASE',
'com.jgoodies:looks:2.2.2',
'com.jgoodies:animation:1.2.0',
'com.jgoodies:binding:2.0.6',
'com.jgoodies:forms:1.2.1',
'com.jgoodies:validation:2.0.1'
testCompile 'junit:junit:4.7',
'org.unitils:unitils-spring:3.1',
'org.unitils:unitils-easymock:3.1',
'org.unitils:unitils-inject:3.1',
'org.springframework:spring-test:3.0.5.RELEASE'
}
manifest.mainAttributes(
'Implementation-Title': 'victoria',
'Implementation-Version': version,
'Main-Class': 'com.sirius.opas.client.Client',
'Class-Path':manifestClasspath() )
task release(dependsOn: 'jar') << {
ant.delete(dir:releaseDir, quiet:"true" )
ant.mkdir(dir:releaseDir)
copy {
from configurations.compile
into "${releaseDir}/${releaseLibDir}"
}
copy {
from "$libsDir/${archivesBaseName}-${version}.jar"
from "dist/start.sh"
from "dist/start.cmd"
into "${releaseDir}"
}
}
String manifestClasspath() {
String classes = ""
configurations.compile.files.each { file ->
classes += " ${releaseLibDir}/${file.name}"
}
return classes
}
I think you are simply missing a dependency that provides BeanDefinition class. Try adding 'org.springframework:spring-beans:3.0.5.RELEASE' to your compile dependencies list.

Resources