Reputation: 21
I am trying to build and imported Android project in Android Studio/Eclipse.
My goal is to write automated test to the current project. First, I am trying to build the project and then to make an apk file of it so I will be able to execute real device/emulator tests on it.
Here are my available Gradle tasks
There is no build or test or assemble and etc. tasks which are I am looking to use so I will reach my goal.
Here is my project tree and both build.gradle files
`
apply plugin: "java"
repositories {
jcenter()
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.13
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.android.application'
version = "1.2"
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "sdk.mobfox.com.appcore"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
archivesBaseName = "MobFox-Android-SDK-Client-" + version + ".apk"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize = "4g"
}
lintOptions {
abortOnError false
}
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services-ads:11.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.danikula:videocache:2.7.0'
testCompile 'junit:junit:4.12'}
I tried to open the project in Android Studio but got the same state. I opened a new Gradle project in Eclipse and saw that the tasks I am looking for are available there - I believe because of the 'java-library' plugin which added to the build.gradle root file but I use the same plugin in my root build file and did not receive what I expected. I was succeeded to execute the Gradle "tasks" which gave me the next response in console :
Working Directory: C:\Users\orit\Desktop\mobFox\MobFox-Android-SDK-master\MobFox-Android-SDK-master Gradle User Home: C:\Users\orit.gradle Gradle Distribution: Specific Gradle version 4.1 Gradle Version: 4.1 Java Home: C:\Program Files\Java\jdk1.8.0_91 JVM Arguments: None Program Arguments: None Gradle Tasks: tasks
:tasks
assemble - Assembles the outputs of this project. build - Assembles and tests this project. buildDependents - Assembles and tests this project and all projects that depend on it. buildNeeded - Assembles and tests this project and all projects it depends on. classes - Assembles main classes. clean - Deletes the build directory. jar - Assembles a jar archive containing the main classes. testClasses - Assembles test classes.
init - Initializes a new Gradle build. wrapper - Generates Gradle wrapper files.
javadoc - Generates Javadoc API documentation for the main source code.
buildEnvironment - Displays all buildscript dependencies declared in root project 'MobFox-Android-SDK-master'. components - Displays the components produced by root project 'MobFox-Android-SDK-master'. [incubating] dependencies - Displays all dependencies declared in root project 'MobFox-Android-SDK-master'. dependencyInsight - Displays the insight into a specific dependency in root project 'MobFox-Android-SDK-master'. dependentComponents - Displays the dependent components of components in root project 'MobFox-Android-SDK-master'. [incubating] help - Displays a help message. model - Displays the configuration model of root project 'MobFox-Android-SDK-master'. [incubating] projects - Displays the sub-projects of root project 'MobFox-Android-SDK-master'. properties - Displays the properties of root project 'MobFox-Android-SDK-master'. tasks - Displays the tasks runnable from root project 'MobFox-Android-SDK-master'.
check - Runs all checks. test - Runs the unit tests.
Pattern: clean: Cleans the output files of a task. Pattern: build: Assembles the artifacts of a configuration. Pattern: upload: Assembles and uploads the artifacts belonging to a configuration. To see all tasks and more detail, run gradle tasks --all To see more detail about a task, run gradle help --task BUILD SUCCESSFUL in 0s 1 actionable task: 1 executed
**1. What is the reason I cannot get all the task I got when I open a new project?
Upvotes: 0
Views: 2154
Reputation: 7221
Applying com.android.application
should be enough, you should not apply java plugin
on the root either and add dependencies there.
Operate on your app project, with Java specific stuff.
For more reference how to structure your project. https://developer.android.com/studio/build/index.html
Upvotes: 0
Reputation: 7636
task
, you write in project level build.gradle file. See below pic for the reference.
You are posting module level build.grale file.
Upvotes: 0