Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Suggestions from following the Getting Started guide #220

Merged

Conversation

AngusP
Copy link
Contributor

@AngusP AngusP commented Mar 19, 2024

I've added a few pointers for things I got stuck on or had to check when following the 'Getting Started' guide in the book.

Some of these will be helpful for Rust devs that aren't that familiar with app development, and others hopefully avoid getting stuck where there's sensitivity to exact naming or setup.

I've added a few pointers for things I got stuck on or had to check when following the 'Getting Started' guide in the book.
Some of these will be helpful for Rust devs that aren't that familiar with app development, and others hopefully avoid getting stuck where there's sensitivity to exact naming or setup.
Comment on lines +126 to +128
```admonish warning title="Sharp edge"
You will need to set the `ndkVersion` to one you have installed, go to "**Tools, SDK Manager, SDK Tooks**" and check "**Show Package Details**" to get your installed version, or to install the version matching `build.gradle` above.
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there's an easier way around this, like some way to say "latest"? The error message if the version mismatches is an unhelpful NDK is not installed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is good. Thanks!

* "Package name": `com.example.simple_counter`
* "Save Location": a directory called `Android` at the root of our monorepo
* "Minimum SDK" `API 34`
* "Build configuration language": `Groovy DSL (build.gradle)`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me Android Studio was defaulting to build.gradle.kts build files, which ofc won't then work with the copy-pastes later.

"Empty Activity". In this walk-through, we'll call it "Counter"

* "Name": `Counter`
* "Package name": `com.example.simple_counter`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is important, e.g. if I chose a different namespace like com.random_tutorials.simple_counter you'd then have a problem later as the shared library will be in the com.example. namespace? (Maybe I'm wrong, I'm not an Android/Java dev 😅)

@AngusP
Copy link
Contributor Author

AngusP commented Mar 19, 2024

I did also wonder, for iOS you add the targets to rust-toolchain.toml

[toolchain]
channel = "stable"
components = ["rustfmt", "rustc-dev"]
targets = [
  "aarch64-apple-darwin",
  "aarch64-apple-ios",
  "aarch64-apple-ios-sim",
  "aarch64-linux-android",
  "wasm32-unknown-unknown",
  "x86_64-apple-ios"
]
profile = "minimal"

Why don't you also add the Android ones, that instead we installed by manually running rustup later?

$ rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android

to have this:

[toolchain]
channel = "stable"
components = ["rustfmt", "rustc-dev"]
targets = [
  "aarch64-apple-darwin",
  "aarch64-apple-ios",
  "aarch64-apple-ios-sim",
  "aarch64-linux-android",
  "armv7-linux-androideabi",
  "i686-linux-android",
  "wasm32-unknown-unknown",
  "x86_64-apple-darwin",
  "x86_64-apple-ios",
  "x86_64-linux-android",
]
profile = "minimal"

@AngusP
Copy link
Contributor Author

AngusP commented Mar 19, 2024

Last point I'm not sure about is your build.gradle examples look like this:

dependencies {
    // our shared library
    implementation project(path: ':shared')

    def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
    implementation composeBom
    androidTestImplementation composeBom

    implementation 'androidx.compose.material3:material3:1.2.0-beta01'
    ...
}

whereas the ones Android Studio generated for me look like

dependencies {
    // our shared library
    implementation project(path: ":shared")

    implementation libs.androidx.core.ktx
    implementation libs.androidx.lifecycle.runtime.ktx
    implementation libs.androidx.activity.compose
   ...
}

It wasn't that hard to mentally diff them and add the bits needed but it's a little confusing for a noob! I'd hazard a guess it's best-practice to give fixed versions but for a tutorial that might also be a bit brittle (i.e. might just stop working in a few months/years?)

(I did also have to click something that then added implementation libs.androidx.lifecycle.viewmodel.compose in lieu of implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2") but that will be because I missed it when manually diff'ing.)

Copy link
Member

@StuartHarris StuartHarris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this — much appreciated.

Comment on lines +126 to +128
```admonish warning title="Sharp edge"
You will need to set the `ndkVersion` to one you have installed, go to "**Tools, SDK Manager, SDK Tooks**" and check "**Show Package Details**" to get your installed version, or to install the version matching `build.gradle` above.
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is good. Thanks!

@StuartHarris StuartHarris merged commit f419056 into redbadger:master Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants