Skip to content

Need to update instructions for running hello_services app in Android Studio #6539

@raju-bitter

Description

@raju-bitter

Steps to Reproduce

With the instructions provided here https://github.com/flutter/flutter/tree/master/examples/hello_services, I was not able to run the hello_services app on an Android device. Instead here is what I had to do:

1) Checkout Flutter source
git clone https://github.com/flutter/flutter

2) In examples/hello_services/android, create local.properties file
Content for my setup:
sdk.dir=/Users/raju/Library/Android/sdk
flutter.sdk=/Users/raju/dev/flutter
flutter.buildMode=debug

3) Open project folder examples/hello_services/android with Android Studio
Tested with Android Studio 2.2.2. The IDE will show a message like:
"Gradle settings for this project not configured yet.
Would you like the project to use the Gradle wrapper?"

Clicked OK, Android Studio will index and build the project. Shows error message:

Error:Cause: failed to find target with hash string 'android-22' in: /Users/raju/Library/Android/sdk
Install missing platform(s) and sync project

I have Android SDK 6.0 installed, with SDK Build tools 24.0.0.

4) Set the SDK target version
In file examples/hello_services/android/app/build.gradle, I set the following
version numbers:

android {
compileSdkVersion 23
buildToolsVersion '24.0.3'

5) Rebuild project
Output:

Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources]

Configuration on demand is an incubating feature.
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE
Incremental java compilation is an incubating feature.
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:flutterBuild
Built /Users/raju/test2/flutter/examples/hello_services/android/app/build/intermediates/flutter/app.flx.
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:copyFlutterAssetsDebug
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:mockableAndroidJar
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:mergeDebugAndroidTestShaders
:app:compileDebugAndroidTestShaders
:app:generateDebugAndroidTestAssets
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).

/Users/raju/test2/flutter/examples/hello_services/android/app/src/main/java/com/example/flutter/ExampleActivity.java:20: error: package org.domokit.activity does not exist
import org.domokit.activity.ActivityImpl;
^
1 error

:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.4 secs

6) Fix compile error by commenting out line #20 in ExampleActivity.java
To fix this compile error, I commented out this line and rebuild the project.
hello_services/android/app/src/main/java/com/example/flutter/ExampleActivity.java:20

Build output:

Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources]

Configuration on demand is an incubating feature.
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE
Incremental java compilation is an incubating feature.
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:flutterBuild
Built /Users/raju/test2/flutter/examples/hello_services/android/app/build/intermediates/flutter/app.flx.
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:copyFlutterAssetsDebug
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:mockableAndroidJar
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:mergeDebugAndroidTestShaders
:app:compileDebugAndroidTestShaders
:app:generateDebugAndroidTestAssets
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:incrementalDebugUnitTestJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugUnitTestJavaWithJavac UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:processDebugUnitTestJavaRes UP-TO-DATE
:app:compileDebugUnitTestSources UP-TO-DATE
:app:incrementalDebugAndroidTestJavaCompilationSafeguard
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources

BUILD SUCCESSFUL

Total time: 4.227 secs

7) Launch flutter.run from hello_services folder

[raju@Spitsbergen:~/test2/flutter/examples/hello_services]$ flutter run
Running 'gradlew build'...
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:flutterBuild
Built /Users/raju/test2/flutter/examples/hello_services/android/app/build/intermediates/flutter/app.flx.
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:copyFlutterAssetsDebug
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:prePackageMarkerForDebug
:app:transformClassesWithDexForDebug
Merged dex #1 (10 defs/7.2KiB)
Merged dex #2 (436 defs/381.1KiB)
Result is 446 defs/471.2KiB. Took 0.1s
:app:mergeDebugJniLibFolders
:app:transformNative_libsWithMergeJniLibsForDebug
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug
:app:validateDebugSigning
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:mergeReleaseShaders
:app:compileReleaseShaders
:app:generateReleaseAssets
:app:mergeReleaseAssets
:app:copyFlutterAssetsRelease
:app:generateReleaseResValues
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:incrementalReleaseJavaCompilationSafeguard
:app:compileReleaseJavaWithJavac
:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:lintVitalRelease
:app:prePackageMarkerForRelease
:app:transformClassesWithDexForRelease
Merged dex #1 (436 defs/381.1KiB)
Merged dex #2 (10 defs/7.1KiB)
Result is 446 defs/471.1KiB. Took 0.0s
:app:mergeReleaseJniLibFolders
:app:transformNative_libsWithMergeJniLibsForRelease
:app:processReleaseJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForRelease
:app:packageRelease
:app:assembleRelease
:app:assemble
:app:compileLint
:app:lint
Ran lint on variant debug: 5 issues found
Ran lint on variant release: 5 issues found
Wrote HTML report to file:///Users/raju/test2/flutter/examples/hello_services/android/app/build/outputs/lint-results-debug.html
Wrote XML report to file:///Users/raju/test2/flutter/examples/hello_services/android/app/build/outputs/lint-results-debug.xml
:app:incrementalDebugUnitTestJavaCompilationSafeguard UP-TO-DATE
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:compileDebugUnitTestJavaWithJavac UP-TO-DATE
:app:processDebugUnitTestJavaRes UP-TO-DATE
:app:compileDebugUnitTestSources UP-TO-DATE
:app:mockableAndroidJar UP-TO-DATE
:app:assembleDebugUnitTest UP-TO-DATE
:app:testDebugUnitTest
:app:incrementalReleaseUnitTestJavaCompilationSafeguard UP-TO-DATE
:app:preReleaseUnitTestBuild UP-TO-DATE
:app:prepareReleaseUnitTestDependencies
:app:compileReleaseUnitTestJavaWithJavac UP-TO-DATE
:app:processReleaseUnitTestJavaRes UP-TO-DATE
:app:compileReleaseUnitTestSources UP-TO-DATE
:app:assembleReleaseUnitTest UP-TO-DATE
:app:testReleaseUnitTest
:app:test
:app:check
:app:build

BUILD SUCCESSFUL

Total time: 19.679 secs

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Built android/app/build/outputs/apk/app-debug.apk (8.6MB).
Launching loader on Lumigon T3...
--------- beginning of main
Observatory listening on http://127.0.0.1:8102
Diagnostic server listening on http://127.0.0.1:8103
Syncing files to device... 4065ms
Synced 3.9MB.
Connected to _flutterView/0xea70a8c0.
Running lib/main.dart on Lumigon T3...
I/flutter : [INFO:engine.cc(181)] Could not configure asset bundle at path: /data/user/0/com.example.flutter/cache/hello_servicesbqaore/build/flx
Application running.
Type "h" or F1 for this help message; type "q", F10, or ctrl-c to quit.
Type "r" or F5 to perform a hot reload of the app, and "R" to restart the app.
Type "w" to print the widget hierarchy of the app, and "t" for the render tree.
Syncing files to device... 5507ms

Flutter Doctor

[✓] Flutter (on Mac OS, channel master)
• Flutter at /Users/raju/dev/flutter
• Framework revision 8cd1b79 (4 hours ago), 2016-10-25 14:04:23
• Engine revision 9f65114
• Tools Dart version 1.21.0-dev.0.0

[✓] Android toolchain - develop for Android devices (Android SDK 24.0.3)
• Android SDK at /Users/raju/Library/Android/sdk
• Platform android-24, build-tools 24.0.3
• Java(TM) SE Runtime Environment (build 1.8.0_101-b13)

[✓] iOS toolchain - develop for iOS devices (Xcode 8.0)
• XCode at /Applications/Xcode.app/Contents/Developer
• Xcode 8.0, Build version 8A218a

[✓] Atom - a lightweight development environment for Flutter
• flutter plugin version 0.2.6
• dartlang plugin version 0.6.42

[-] IntelliJ IDEA Community Edition (version 2016.2.5)
• Dart plugin not installed; this adds Dart specific functionality.
• Flutter plugin not installed; this adds Flutter specific functionality.
• For information about managing plugins, see
https://www.jetbrains.com/help/idea/2016.2/managing-plugins.html

[✓] Connected devices
• Lumigon T3 • 30067719 • android-arm

Metadata

Metadata

Assignees

Labels

platform-androidAndroid applications specifically

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions