ejecutar HelloAndroid desde Gradle?

Hay un abrumador número y variedad de tareas de gradle:

thufir@dur:~/AndroidStudioProjects/HelloAndroid$ thufir@dur:~/AndroidStudioProjects/HelloAndroid$ gradle clean run FAILURE: Build failed with an exception. * What went wrong: Task 'run' not found in root project 'HelloAndroid'. * Try: Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org BUILD FAILED in 0s thufir@dur:~/AndroidStudioProjects/HelloAndroid$ thufir@dur:~/AndroidStudioProjects/HelloAndroid$ gradle tasks --all > Task :tasks ------------------------------------------------------------ All tasks runnable from root project ------------------------------------------------------------ Android tasks ------------- app:androidDependencies - Displays the Android dependencies of the project. app:signingReport - Displays the signing info for each variant. app:sourceSets - Prints out all the source sets defined in this project. Build tasks ----------- app:assemble - Assembles all variants of all applications and secondary packages. app:assembleAndroidTest - Assembles all the Test applications. app:assembleDebug - Assembles all Debug builds. app:assembleRelease - Assembles all Release builds. app:build - Assembles and tests this project. app:buildDependents - Assembles and tests this project and all projects that depend on it. app:buildNeeded - Assembles and tests this project and all projects it depends on. app:clean - Deletes the build directory. app:cleanBuildCache - Deletes the build cache directory. app:compileDebugAndroidTestSources app:compileDebugSources app:compileDebugUnitTestSources app:compileReleaseSources app:compileReleaseUnitTestSources app:mockableAndroidJar - Creates a version of android.jar that's suitable for unit tests. Build Setup tasks ----------------- init - Initializes a new Gradle build. wrapper - Generates Gradle wrapper files. Help tasks ---------- buildEnvironment - Displays all buildscript dependencies declanetworking in root project 'HelloAndroid'. app:buildEnvironment - Displays all buildscript dependencies declanetworking in project ':app'. components - Displays the components produced by root project 'HelloAndroid'. [incubating] app:components - Displays the components produced by project ':app'. [incubating] dependencies - Displays all dependencies declanetworking in root project 'HelloAndroid'. app:dependencies - Displays all dependencies declanetworking in project ':app'. dependencyInsight - Displays the insight into a specific dependency in root project 'HelloAndroid'. app:dependencyInsight - Displays the insight into a specific dependency in project ':app'. dependentComponents - Displays the dependent components of components in root project 'HelloAndroid'. [incubating] app:dependentComponents - Displays the dependent components of components in project ':app'. [incubating] help - Displays a help message. app:help - Displays a help message. model - Displays the configuration model of root project 'HelloAndroid'. [incubating] app:model - Displays the configuration model of project ':app'. [incubating] projects - Displays the sub-projects of root project 'HelloAndroid'. app:projects - Displays the sub-projects of project ':app'. properties - Displays the properties of root project 'HelloAndroid'. app:properties - Displays the properties of project ':app'. tasks - Displays the tasks runnable from root project 'HelloAndroid' (some of the displayed tasks may belong to subprojects). app:tasks - Displays the tasks runnable from project ':app'. Install tasks ------------- app:installDebug - Installs the Debug build. app:installDebugAndroidTest - Installs the android (on device) tests for the Debug build. app:uninstallAll - Uninstall all applications. app:uninstallDebug - Uninstalls the Debug build. app:uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build. app:uninstallRelease - Uninstalls the Release build. Verification tasks ------------------ app:check - Runs all checks. app:connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices. app:connectedCheck - Runs all device checks on currently connected devices. app:connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices. app:deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers. app:deviceCheck - Runs all device checks using Device Providers and Test Servers. app:lint - Runs lint on all variants. app:lintDebug - Runs lint on the Debug build. app:lintRelease - Runs lint on the Release build. app:lintVitalRelease - Runs lint on just the fatal issues in the release build. app:test - Run unit tests for all variants. app:testDebugUnitTest - Run unit tests for the debug build. app:testReleaseUnitTest - Run unit tests for the release build. Other tasks ----------- app:assembleDebugAndroidTest app:assembleDebugUnitTest app:assembleReleaseUnitTest app:bundleAppClassesDebug app:bundleAppClassesDebugAndroidTest app:bundleAppClassesDebugUnitTest app:bundleAppClassesRelease app:bundleAppClassesReleaseUnitTest app:checkDebugManifest app:checkReleaseManifest clean app:compileDebugAidl app:compileDebugAndroidTestAidl app:compileDebugAndroidTestJavaWithJavac app:compileDebugAndroidTestKotlin - Compiles the debugAndroidTest kotlin. app:compileDebugAndroidTestNdk app:compileDebugAndroidTestRenderscript app:compileDebugAndroidTestShaders app:compileDebugJavaWithJavac app:compileDebugKotlin - Compiles the debug kotlin. app:compileDebugNdk app:compileDebugRenderscript app:compileDebugShaders app:compileDebugUnitTestJavaWithJavac app:compileDebugUnitTestKotlin - Compiles the debugUnitTest kotlin. app:compileLint app:compileReleaseAidl app:compileReleaseJavaWithJavac app:compileReleaseKotlin - Compiles the release kotlin. app:compileReleaseNdk app:compileReleaseRenderscript app:compileReleaseShaders app:compileReleaseUnitTestJavaWithJavac app:compileReleaseUnitTestKotlin - Compiles the releaseUnitTest kotlin. app:consumeConfigAttr app:createDebugCompatibleScreenManifests app:createReleaseCompatibleScreenManifests app:extractProguardFiles app:generateDebugAndroidTestAssets app:generateDebugAndroidTestBuildConfig app:generateDebugAndroidTestResources app:generateDebugAndroidTestResValues app:generateDebugAndroidTestSources app:generateDebugAssets app:generateDebugBuildConfig app:generateDebugResources app:generateDebugResValues app:generateDebugSources app:generateReleaseAssets app:generateReleaseBuildConfig app:generateReleaseResources app:generateReleaseResValues app:generateReleaseSources app:javaPreCompileDebug app:javaPreCompileDebugAndroidTest app:javaPreCompileDebugUnitTest app:javaPreCompileRelease app:javaPreCompileReleaseUnitTest app:mergeDebugAndroidTestAssets app:mergeDebugAndroidTestJniLibFolders app:mergeDebugAndroidTestResources app:mergeDebugAndroidTestShaders app:mergeDebugAssets app:mergeDebugJniLibFolders app:mergeDebugResources app:mergeDebugShaders app:mergeReleaseAssets app:mergeReleaseJniLibFolders app:mergeReleaseResources app:mergeReleaseShaders app:packageDebug app:packageDebugAndroidTest app:packageRelease app:platformAttrExtractor app:preBuild app:preDebugAndroidTestBuild app:preDebugBuild app:preDebugUnitTestBuild app:prepareLintJar app:preReleaseBuild app:preReleaseUnitTestBuild app:processDebugAndroidTestJavaRes app:processDebugAndroidTestManifest app:processDebugAndroidTestResources app:processDebugJavaRes app:processDebugManifest app:processDebugResources app:processDebugUnitTestJavaRes app:processReleaseJavaRes app:processReleaseManifest app:processReleaseResources app:processReleaseUnitTestJavaRes app:resolveConfigAttr app:splitsDiscoveryTaskDebug app:splitsDiscoveryTaskDebugAndroidTest app:splitsDiscoveryTaskRelease app:transformClassesWithDexBuilderForDebug app:transformClassesWithDexBuilderForDebugAndroidTest app:transformClassesWithPreDexForRelease app:transformDexArchiveWithDexMergerForDebug app:transformDexArchiveWithDexMergerForDebugAndroidTest app:transformDexArchiveWithExternalLibsDexMergerForDebug app:transformDexArchiveWithExternalLibsDexMergerForDebugAndroidTest app:transformDexWithDexForRelease app:transformNativeLibsWithMergeJniLibsForDebug app:transformNativeLibsWithMergeJniLibsForDebugAndroidTest app:transformNativeLibsWithMergeJniLibsForRelease app:transformResourcesWithMergeJavaResForDebug app:transformResourcesWithMergeJavaResForDebugAndroidTest app:transformResourcesWithMergeJavaResForDebugUnitTest app:transformResourcesWithMergeJavaResForRelease app:transformResourcesWithMergeJavaResForReleaseUnitTest app:validateSigningDebug app:validateSigningDebugAndroidTest app:writeDebugApplicationId app:writeReleaseApplicationId BUILD SUCCESSFUL in 1s 1 actionable task: 1 executed thufir@dur:~/AndroidStudioProjects/HelloAndroid$ thufir@dur:~/AndroidStudioProjects/HelloAndroid$ gradle clean BUILD SUCCESSFUL in 0s 2 actionable tasks: 1 executed, 1 up-to-date thufir@dur:~/AndroidStudioProjects/HelloAndroid$ thufir@dur:~/AndroidStudioProjects/HelloAndroid$ tree . ├── app │  ├── build.gradle │  ├── libs │  ├── proguard-rules.pro │  └── src │  ├── androidTest │  │  └── java │  │  └── android │  │  └── kotlin │  │  └── dur │  │  └── bounceme │  │  └── net │  │  └── helloandroid │  │  └── ExampleInstrumentedTest.kt │  ├── main │  │  ├── AndroidManifest.xml │  │  ├── java │  │  │  └── android │  │  │  └── kotlin │  │  │  └── dur │  │  │  └── bounceme │  │  │  └── net │  │  │  └── helloandroid │  │  │  └── MainActivity.kt │  │  └── res │  │  ├── drawable │  │  │  ├── ic_dashboard_black_24dp.xml │  │  │  ├── ic_home_black_24dp.xml │  │  │  ├── ic_launcher_background.xml │  │  │  └── ic_notifications_black_24dp.xml │  │  ├── drawable-v24 │  │  │  └── ic_launcher_foreground.xml │  │  ├── layout │  │  │  └── activity_main.xml │  │  ├── menu │  │  │  └── navigation.xml │  │  ├── mipmap-anydpi-v26 │  │  │  ├── ic_launcher_round.xml │  │  │  └── ic_launcher.xml │  │  ├── mipmap-hdpi │  │  │  ├── ic_launcher.png │  │  │  └── ic_launcher_round.png │  │  ├── mipmap-mdpi │  │  │  ├── ic_launcher.png │  │  │  └── ic_launcher_round.png │  │  ├── mipmap-xhdpi │  │  │  ├── ic_launcher.png │  │  │  └── ic_launcher_round.png │  │  ├── mipmap-xxhdpi │  │  │  ├── ic_launcher.png │  │  │  └── ic_launcher_round.png │  │  ├── mipmap-xxxhdpi │  │  │  ├── ic_launcher.png │  │  │  └── ic_launcher_round.png │  │  └── values │  │  ├── colors.xml │  │  ├── dimens.xml │  │  ├── strings.xml │  │  └── styles.xml │  └── test │  └── java │  └── android │  └── kotlin │  └── dur │  └── bounceme │  └── net │  └── helloandroid │  └── ExampleUnitTest.kt ├── build │  ├── android-profile │  │  ├── profile-2017-11-05-17-50-01-533.json │  │  └── profile-2017-11-05-17-50-01-533.rawproto │  └── kotlin-build │  └── version.txt ├── build.gradle ├── gradle │  └── wrapper │  ├── gradle-wrapper.jar │  └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── HelloAndroid.iml ├── local.properties └── settings.gradle 44 directories, 41 files thufir@dur:~/AndroidStudioProjects/HelloAndroid$ 

Desde Android Studio :

correr

dispositivo virtual?

La "carrera" más simple posible es lo que busco. ¿Algo similar a runShadow ?

Código generado y file de compilation:

 thufir@dur:~/AndroidStudioProjects/HelloAndroid$ thufir@dur:~/AndroidStudioProjects/HelloAndroid$ cat build.gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.51' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } thufir@dur:~/AndroidStudioProjects/HelloAndroid$ thufir@dur:~/AndroidStudioProjects/HelloAndroid$ cat app/src/main/java/android/kotlin/dur/bounceme/net/helloandroid/MainActivity.kt package android.kotlin.dur.bounceme.net.helloandroid import android.os.Bundle import android.support.design.widget.BottomNavigationView import android.support.v7.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() { private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item -> when (item.itemId) { R.id.navigation_home -> { message.setText(R.string.title_home) return@OnNavigationItemSelectedListener true } R.id.navigation_dashboard -> { message.setText(R.string.title_dashboard) return@OnNavigationItemSelectedListener true } R.id.navigation_notifications -> { message.setText(R.string.title_notifications) return@OnNavigationItemSelectedListener true } } false } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener) } } thufir@dur:~/AndroidStudioProjects/HelloAndroid$ 

gradle run no se usa para el proyecto de Android, testing una de las tareas de ensamblaje [Flavor]. Para "instalar y ejecutar" una aplicación en un emulador o dispositivo Android, hay 3 pasos:

1) Crea el apk. Por ejemplo, primero tendrá que ejecutar:

 $ ./gradlew clean assembleDebug 

Eso va a generar un file apk, y asumiré que el apk generado se llama app-debug.apk.

2) Instale el apk generado en su dispositivo o emulador:

 $ adb install -r app/build/outputs/apk/debug/app-debug.apk 

Si tenía instalado adb y un emulador en ejecución o un dispositivo conectado, la salida debería ser "Correcta". La opción -r se usa si ya tiene instalada la misma aplicación, puede get más información sobre otras opciones de installation de adb.

3) "Ejecuta" tu aplicación en tu emulador o dispositivo:

 $ adb shell am start -n "android.kotlin.dur.bounceme.net.helloandroid/android.kotlin.dur.bounceme.net.helloandroid.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER 

Supongo que su Iniciador es su actividad principal, puede cambiar eso en el file AndroidManifest.xml, y también necesitará el nombre del package.