diff --git a/_android/images/blockstack-install.png b/_android/images/blockstack-install.png deleted file mode 100644 index 5e4d6256..00000000 Binary files a/_android/images/blockstack-install.png and /dev/null differ diff --git a/_android/images/blockstack-signin.png b/_android/images/blockstack-signin.png index 081d5050..e9d825a3 100644 Binary files a/_android/images/blockstack-signin.png and b/_android/images/blockstack-signin.png differ diff --git a/_android/images/chrome-prompt.png b/_android/images/chrome-prompt.png deleted file mode 100644 index f60822ab..00000000 Binary files a/_android/images/chrome-prompt.png and /dev/null differ diff --git a/_android/images/configure-activity.png b/_android/images/configure-activity.png index 1be7edf5..2163fffa 100644 Binary files a/_android/images/configure-activity.png and b/_android/images/configure-activity.png differ diff --git a/_android/images/connect-response.png b/_android/images/connect-response.png new file mode 100644 index 00000000..de8a94f3 Binary files /dev/null and b/_android/images/connect-response.png differ diff --git a/_android/images/connect-ui.png b/_android/images/connect-ui.png new file mode 100644 index 00000000..d1f2c47f Binary files /dev/null and b/_android/images/connect-ui.png differ diff --git a/_android/images/create-restore.png b/_android/images/create-restore.png index 914b26e5..867bf009 100644 Binary files a/_android/images/create-restore.png and b/_android/images/create-restore.png differ diff --git a/_android/images/final-app.png b/_android/images/final-app.png index 01f62b83..3b288466 100644 Binary files a/_android/images/final-app.png and b/_android/images/final-app.png differ diff --git a/_android/images/helloandroid.zip b/_android/images/helloandroid.zip index 672ab7e0..da97d4da 100644 Binary files a/_android/images/helloandroid.zip and b/_android/images/helloandroid.zip differ diff --git a/_android/images/initial-build.png b/_android/images/initial-build.png deleted file mode 100644 index 601f3e8a..00000000 Binary files a/_android/images/initial-build.png and /dev/null differ diff --git a/_android/images/new-interface.png b/_android/images/new-interface.png index d434f9bb..e0d02fc1 100644 Binary files a/_android/images/new-interface.png and b/_android/images/new-interface.png differ diff --git a/_android/images/oreo-api.png b/_android/images/oreo-api.png deleted file mode 100644 index 1de35691..00000000 Binary files a/_android/images/oreo-api.png and /dev/null differ diff --git a/_android/images/q-api.png b/_android/images/q-api.png new file mode 100644 index 00000000..a18f95c9 Binary files /dev/null and b/_android/images/q-api.png differ diff --git a/_android/images/running-app.png b/_android/images/running-app.png index 9838c05f..38f0ee75 100644 Binary files a/_android/images/running-app.png and b/_android/images/running-app.png differ diff --git a/_android/images/select-hdw.png b/_android/images/select-hdw.png index 2eaccb4f..32057101 100644 Binary files a/_android/images/select-hdw.png and b/_android/images/select-hdw.png differ diff --git a/_android/images/sync-project.png b/_android/images/sync-project.png index b5e5c141..75bc4805 100644 Binary files a/_android/images/sync-project.png and b/_android/images/sync-project.png differ diff --git a/_android/images/sync-success.png b/_android/images/sync-success.png index 62ae3f5d..6798ad69 100644 Binary files a/_android/images/sync-success.png and b/_android/images/sync-success.png differ diff --git a/_android/tutorial.md b/_android/tutorial.md index 1cc57501..879e76bb 100644 --- a/_android/tutorial.md +++ b/_android/tutorial.md @@ -3,21 +3,22 @@ layout: learn description: Learn about the Android SDK permalink: /:collection/:path.html --- + # Android DApps + {:.no_toc} This tutorial is written for readers who are new to either or both Blockstack and Android to create a decentralized application. It contains the following content: -* TOC +TOC {:toc} -This tutorial was extensively tested using Android Studio 3.1 on a MacBook Air -running High Sierra 10.13.4. If your environment is different, you may encounter +This tutorial was extensively tested using Android Studio 3.6 on a Dell XPS 13 +running Ubuntu 19. If your environment is different, you may encounter slight or even major discrepancies when performing the procedures in this -tutorial. Please [join the Blockstack community -Slack](https://slofile.com/slack/blockstack) and post questions or comments to +tutorial. Please [join the Blockstack discord server](https://chat.blockstack.org) and post questions or comments to the `#support` channel. Finally, this tutorial is written for all levels from the beginner to the most @@ -36,7 +37,7 @@ intended for user on an Android phone. ![](images/final-app.png) -Only users with an existing `blockstack.id` can run your +Only users with an existing blockstack id can run your final sample application. When complete, users interact with the sample application by doing the following: @@ -45,7 +46,7 @@ application by doing the following: ## Set up your environment This sample application has two code bases, a Blockstack `hello-blockstack` -application and a `hello-andriod` Android application. Before you start +web application and a `hello-andriod` Android application. Before you start developing the sample, there are a few elements you need in your environment. ### Install Android Studio @@ -56,7 +57,7 @@ step. However, you will need to adjust the remaining instructions for your environment. Follow the installation instructions to download and [Android Studio -3.1](https://developer.android.com/studio/install) for your operating system. +3.6](https://developer.android.com/studio/install) for your operating system. Depending on your network connection, this can take between 15-30 minutes. ![](images/studio-download.png) @@ -75,27 +76,9 @@ $ which npm npx If you don't have these installed, take a moment to install or upgrade as needed. -### Install the Blockstack test rig - -Users interact with Blockstack-enabled applications through a web browser. You -can Blockstack in test mode, on `localhost` or you can interact with completed -apps through the Blockstack webapp which is available at -[https://browser.blockstack.org/]. - -If you have already installed Blockstack for testing locally and have an -existing Blockstack ID, skip this section. Otherwise, continue onto install -Blockstack. - -1. Go to [Blockstack](https://blockstack.org/install) - - ![](images/blockstack-install.png) - -2. Install the version appropriate for your operating system. - -## Build the Blockstack hello-world +## Build the Blockstack hello-world web app -In this section, you build a Blockstack `hello-world` application. Then, you -modify the `hello-world` to interact with the Android app via a redirect. +In this section, you build a Blockstack `hello-world` web application that acts as the companion site to your Android application. ### Generate and launch your hello-blockstack application @@ -106,74 +89,66 @@ In this section, you build an initial React.js application called 1. Create a `hello-blockstack` directory. - ```bash - mkdir hello-blockstack - ``` + ```bash + mkdir hello-blockstack + ``` 2. Change into your new directory. - ```bash - cd hello-blockstack - ``` + ```bash + cd hello-blockstack + ``` 3. Use the Blockstack application generator to create your initial `hello-blockstack` application. - ```bash - $ npx generator-blockstack --react - npx: installed 338 in 13.792s - create package.json - create .gitignore - create webpack.config.js - create netlify.toml - create firebase.json - ... - I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself. - - > fsevents@1.2.9 install /private/tmp/testymc/node_modules/fsevents - > node install - added 775 packages from 455 contributors and audited 9435 packages in 20.934s - found 0 vulnerabilities - - ``` - - Depending on your environment you may have some warnings with the installation. Optionally, you can fix these before continuing to the next section. - ``` + ```bash + $ npx generator-blockstack --plain + create package.json + create .gitignore + create webpack.config.js + create netlify.toml + create firebase.json + ... + npm WARN ajv-errors@1.0.1 requires a peer of ajv@>=5.0.0 but none is installed. You must install peer dependencies yourself. + + added 840 packages from 582 contributors and audited 843 packages in 18.84s + found 0 vulnerabilities + ``` -4. Respond to the prompts to populate the initial app. + Depending on your environment you may have some warnings with the installation. Optionally, you can fix these before continuing to the next section. - After the process completes successfully, you see a prompt similar to the following: +4. Depending on your environment, respond to the prompts to populate the initial app. + You might see a prompt similar to the following: - ```bash - [fsevents] Success: - "/Users/theuser/repos/hello-blockstack/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" - is installed via remote npm notice created a lockfile as package-lock.json. - You should commit this file. added 1060 packages in 26.901s - ``` + ```bash + [fsevents] Success: + "/Users/theuser/repos/hello-blockstack/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" + is installed via remote npm notice created a lockfile as package-lock.json. + You should commit this file. added 1060 packages in 26.901s + ``` -5. Run the initial application. +5. After the initial setup you can now run the initial application. - ```bash - $ npm run start + ```bash + $ npm run start - > hello-blockstack@0.0.0 start /Users/meepers/repos/hello-blockstack + > hello-blockstack-webpack@0.0.0 start /home/user/hello-blockstack > webpack-dev-server - Project is running at http://localhost:8080/ - webpack output is served from / - 404s will fallback to /index.html - Hash: 4d2312ba236a4b95dc3a - Version: webpack 2.7.0 - Time: 2969ms - Asset Size Chunks Chunk Names - .... - Child html-webpack-plugin for "index.html": - chunk {0} index.html 541 kB [entry] [rendered] - [0] ./~/lodash/lodash.js 540 kB {0} [built] - [1] ./~/html-webpack-plugin/lib/loader.js!./src/index.html 533 bytes {0} [built] - [2] (webpack)/buildin/global.js 509 bytes {0} [built] - [3] (webpack)/buildin/module.js 517 bytes {0} [built] - webpack: Compiled successfully. - ``` + ℹ 「wds」: Project is running at http://localhost:9000/ + ℹ 「wds」: webpack output is served from / + ℹ 「wds」: Content not from webpack is served from /home/user/hello-blockstack/dist + ℹ 「wdm」: Hash: f5d88efe9c9194f66ddd + Version: webpack 4.43.0 + Time: 2733ms + Built at: 05/19/2020 10:44:50 AM + Asset Size Chunks Chunk Names + main.js 5.39 MiB main [emitted] main + .... + [./src/index.js] 1.8 KiB {main} [built] + + 610 hidden modules + ℹ 「wdm」: Compiled successfully. + ``` The system opens a browser displaying your running application. @@ -182,76 +157,23 @@ In this section, you build an initial React.js application called At this point, the browser is running a Blockstack server on your local host. This is for testing your applications only. -6. Choose **Sign in with Blockstack** +6. Choose **Get started** The system displays a prompt allowing you to create a new Blockstack ID or restore an existing one. - ![](images/create-restore.png) + ![](images/create-restore.png) 7. Follow the prompts appropriate to your situation. - If you are restoring an existing ID, you may see a prompt about your user - being nameless, ignore it. At this point you have only a single application - on your test server. So, you should see this single application, with your - own `blockstack.id` display name, once you are signed in: - - ![](images/running-app.png) - - -### Add a redirect end point to your application - -When a user opens the webapp from the Blockstack Browser on an Android phone, -you want the web app to redirect the user to your Android application. The work -you do here will allow it. - -1. From the terminal command line, change directory to the root of your sample -application directory. + At this point you have only a single application + on your test server. So, you should see this single application, with your + own `blockstack.id`, once you are signed in: -2. Use the `touch` command to add a redirect endpoint to your application. - - This endpoint on the web version of your app will redirect Android users back - to your mobile app. - - ```bash - $ touch public/redirect.html - ``` - -3. Open `redirect.html` and add code to the endpoint. - - ```html - - -
-Application Name | -hello-android |
-
---|---|
Company domain | -USERNAME.example.com |
-
Project location | -/Users/USERNAME/AndroidStudioProjects/helloandroid |
-
Include Kotlin support | -Set (checked) | -
Name | +Hello Android |
+
---|---|
Package name | +blockstack.id.USERNAME.hello |
+
Project location | +/home/USERNAME/AndroidStudioProjects/helloandroid |
+
Language | +Select (Kotlin) | +
Minimum SDK | +Select (API 21: Android 5.0 (Lollipop)) | +
+ To use these features, make sure you install the testnet
tag the @blockstack/connect
NPM package. You can do this by running npm install --save @blockstack/connect@testnet
, or by specifying testnet
as the version in
+ your package.json file.
+
The Stacks 2.0 blockchain is still in testnet, and our web app integration is also still in beta. In order to use transaction signing in your application, you need to use the configuration `authOrigin` with `@blockstack/connect`.
@@ -33,34 +26,81 @@ Connect allows you to open the authenticator with parameters indicating the deta