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

Fix android build #105

Closed
wants to merge 7 commits into from
Closed

Fix android build #105

wants to merge 7 commits into from

Conversation

cp-sneha-s
Copy link
Collaborator

@cp-sneha-s cp-sneha-s commented Dec 3, 2024

Purpose

Summary of Changes

Test steps

Conformity

  • Followed git guidelines for creating commit messages and Pull Request guidelines.
  • Self-approved the PR - reviewed the PR as a reviewer and gave it self-approval if everything is ok. If not, made the required changes.
  • Ensured that the PR satisfies all specified requirements in the ticket, including bug fixes and new features.
  • Provided test steps, including steps to reproduce the issue or test the new functionality, ensuring other team members can verify the changes.
  • Added/Updated proper code comments to make it easy-to-understand for other developers.
  • Reused code (if the same code was written twice, made it common and reused it at both places).
  • Removed unused or commented code if not required.
  • Ensured proper Dart naming conventions were used for variables, classes, and methods.
  • Localized user-facing strings.
  • Included screenshots/videos of behavior changes: Provided visual evidence of any changes to UI or behavior for easier review and understanding in the PR description.
  • Implemented proper error handling: Ensured that the code anticipated and handled potential errors and edge cases gracefully.
  • Avoided introducing technical debt: If the PR introduces technical debt, created and linked appropriate tickets for future resolution.
  • Included relevant unit tests: Wrote unit tests that focused on testing behavior and functionality, rather than merely covering lines of code.
  • Ensured code was performant and scalable: Verified that the changes did not introduce performance issues or bottlenecks and could scale as needed.
  • Ensured comments were up-to-date and relevant to the code to describe complex logic and to add understanding for other developers.
  • Marked the PR as ready before submitting it for review.

Visual Evidence (Video, Images or Gif)

Summary by CodeRabbit

  • New Features

    • Updated the app to support Android SDK version 34, enhancing compatibility with the latest Android features.
    • Streamlined the build workflow to trigger on any branch, facilitating more flexible development processes.
    • Introduced a new entry point for the Flutter application with a newly defined MainActivity.
  • Bug Fixes

    • Improved error handling in the sign-in process, allowing for more precise responses to different error conditions.
  • Chores

    • Removed the deprecated multidex application support file, simplifying the project structure.
    • Upgraded the Gradle version to 7.6.3, optimizing build processes.

Copy link

coderabbitai bot commented Dec 3, 2024

Walkthrough

The pull request introduces significant updates to the Android application configuration. The build.gradle file has been restructured to streamline SDK version settings, with minSdkVersion updated from 21 to 34 and namespace set to "com.example.canopas_unity". The .github/workflows/android_build.yml file has been modified to remove branch restrictions, allowing workflows to trigger on any branch and includes jobs for generating both APK and AAB builds. The FlutterMultiDexApplication.java file has been deleted, eliminating multidex support, and several MainActivity.kt files have been removed or replaced.

Changes

File Change Summary
android/app/build.gradle - Set namespace to "com.example.canopas_unity".
- Updated minSdk from 21 to 34.
- Updated compileSdk to flutter.compileSdkVersion.
- Updated applicationId to "com.example.canopas_unity".
- Simplified buildTypes configurations.
.github/workflows/android_build.yml - Removed branch specification under push event trigger.
- Added jobs for android_build_apk and android_build_aab with structured steps for building and uploading artifacts.
android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java - Removed class FlutterMultiDexApplication that supported multidex functionality.
android/gradle/wrapper/gradle-wrapper.properties - Updated distributionUrl from Gradle 7.3 to Gradle 7.6.3.
android/.gitignore - Updated keystore reference comment for clarity.
android/app/src/debug/AndroidManifest.xml - Removed package attribute from <manifest> tag.
- Clarified comment on INTERNET permission.
android/app/src/main/AndroidManifest.xml - Removed package attribute.
- Updated android:label and android:icon attributes.
- Added android:taskAffinity and new <queries> section for text processing.
android/app/src/main/kotlin/com/example/canopas_unity/MainActivity.kt - Added new MainActivity class extending FlutterActivity.
android/app/src/main/res/values/styles.xml - Updated comment regarding splash screen removal timing.
android/app/src/main/res/values-night/styles.xml - Updated comment regarding splash screen removal timing.
android/app/src/profile/AndroidManifest.xml - Removed package attribute from <manifest> tag.
- Clarified comment on INTERNET permission.
android/build.gradle - Standardized string formatting for rootProject.buildDir and evaluationDependsOn.
android/gradle.properties - Updated org.gradle.jvmargs to allocate more memory and enable heap dumps on out-of-memory errors.
android/settings.gradle - Updated plugin versions and removed Google services plugins.
lib/ui/sign_in/bloc/sign_in_view_bloc.dart - Enhanced error handling in _googleSignIn and _appleSignIn methods for more specific responses.

Possibly related PRs

  • Fix pipeline #103: This PR modifies the .github/workflows/android_build.yml file, which is also updated in the main PR. Both PRs involve changes to the Android build workflow, ensuring they are related at the code level.
  • Minor fixes #104: Similar to PR Fix pipeline #103, this PR also updates the .github/workflows/android_build.yml file, specifically adding a distribution parameter for the JDK setup, which connects it to the changes made in the main PR regarding the Android build configuration.

Poem

🐰 In the land of code where bunnies play,
New SDKs hop in, brightening the day.
With versions set high, we leap with glee,
Building our dreams, as sweet as can be!
So let's code away, with joy in our hearts,
For every new change, a fresh start imparts! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
android/app/build.gradle (2)

Line range hint 69-77: Security: Avoid hardcoding signing credentials

The fallback signing configuration contains hardcoded credentials and references a development keystore. This poses security risks if the keystore is committed to the repository.

Recommendations:

  1. Move development signing credentials to a secure location (e.g., local.properties)
  2. Add development.jks to .gitignore
  3. Document the setup process for development signing

Example implementation:

        } else {
            release {
-                keyAlias 'ProjectUnity'
-                keyPassword 'ProjectUnity'
-                storeFile file('development.jks')
-                storePassword 'ProjectUnity'
+                keyAlias localProperties.getProperty('keyAlias')
+                keyPassword localProperties.getProperty('keyPassword')
+                storeFile file(localProperties.getProperty('storeFile'))
+                storePassword localProperties.getProperty('storePassword')
            }
        }

Line range hint 89-97: Incorrect debug build configuration may impact development

The debug build configuration has several issues that could complicate development:

  1. minifyEnabled true in debug builds will make debugging more difficult
  2. Using release signing config for debug builds is unusual and unnecessary
  3. The TODO comment is outdated as signing config is already implemented

Apply these changes to fix the debug configuration:

         debug {
-            // TODO: Add your own signing config for the release build.
-            // Signing with the debug keys for now, so `flutter run --release` works.
-            minifyEnabled true
+            minifyEnabled false
             debuggable true
-
-            signingConfig signingConfigs.release
+            // Use default debug signing config
         }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 929667a and db2dd06.

📒 Files selected for processing (1)
  • android/app/build.gradle (1 hunks)

Comment on lines 51 to 52
minSdkVersion 34
targetSdkVersion 34
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Overly restrictive minSdkVersion will prevent installation on most Android devices

Setting minSdkVersion to 34 (Android 14) will prevent the app from being installed on devices running Android 13 and below, which represents the majority of Android devices in use. This is likely not intended and could severely limit your app's reach.

Consider lowering the minSdkVersion while keeping targetSdkVersion at 34:

-        minSdkVersion 34
+        minSdkVersion 21  // Supports Android 5.0 and above
         targetSdkVersion 34

This change will:

  • Support ~98% of active Android devices
  • Maintain compatibility with latest Android features through targetSdkVersion 34
  • Follow Android best practices for backward compatibility
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
minSdkVersion 34
targetSdkVersion 34
minSdkVersion 21 // Supports Android 5.0 and above
targetSdkVersion 34

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
android/app/build.gradle (2)

Line range hint 29-29: Review build configuration settings

Several configuration issues need attention:

  1. The commented out flutter.compileSdkVersion reference should be removed or used consistently
  2. Debug builds should not have minifyEnabled true as it makes debugging more difficult
  3. Debug builds should use debug signing config instead of release

Apply these changes:

- compileSdkVersion 34//flutter.compileSdkVersion
+ compileSdkVersion flutter.compileSdkVersion

  debug {
-     minifyEnabled true
+     minifyEnabled false
      debuggable true
-     signingConfig signingConfigs.release
+     signingConfig signingConfigs.debug
  }

Also applies to: 89-93


Line range hint 61-69: Address security concerns in signing configuration

  1. Development keystore credentials should not be hardcoded in source control
  2. The TODO comment about signing config can be removed as it's implemented

Consider these changes:

  1. Move development signing config to a separate, gitignored properties file
  2. Remove the outdated TODO comment
- keyAlias 'ProjectUnity'
- keyPassword 'ProjectUnity'
- storeFile file('development.jks')
- storePassword 'ProjectUnity'
+ keyAlias localProperties.getProperty('debug.keyAlias')
+ keyPassword localProperties.getProperty('debug.keyPassword')
+ storeFile file(localProperties.getProperty('debug.storeFile'))
+ storePassword localProperties.getProperty('debug.storePassword')

  buildTypes {
      release {
-         // TODO: Add your own signing config for the release build.
-         // Signing with the debug keys for now, so `flutter run --release` works.

Also applies to: 82-83

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between db2dd06 and 72fac2c.

📒 Files selected for processing (2)
  • .github/workflows/android_build.yml (0 hunks)
  • android/app/build.gradle (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/android_build.yml
🔇 Additional comments (1)
android/app/build.gradle (1)

51-52: LGTM: SDK version configuration is appropriate

The SDK version configuration is well-balanced:

  • minSdkVersion 23 provides good device coverage while maintaining modern API support
  • targetSdkVersion 34 ensures compatibility with the latest Android features

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (1)
lib/ui/sign_in/bloc/sign_in_view_bloc.dart (1)

42-44: Consider logging the exception for better error tracking

In the _googleSignIn method, consider logging the exception to help with debugging and monitoring. Currently, exceptions caught are not being logged or recorded. You can use Firebase Crashlytics or another logging mechanism to record the error details, similar to how it's done in the _appleSignIn method.

Example:

        } catch (e, stack) {
          FirebaseCrashlytics.instance
              .recordError(e, stack, reason: 'Google Sign In Error');
          emit(state.copyWith(
              googleSignInLoading: false, error: firebaseAuthError));
        }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1d4b68c and d860cbb.

⛔ Files ignored due to path filters (10)
  • android/app/src/main/res/mipmap-hdpi/ic_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-hdpi/round_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-mdpi/ic_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-mdpi/round_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-xhdpi/ic_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-xhdpi/round_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-xxhdpi/round_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png is excluded by !**/*.png
  • android/app/src/main/res/mipmap-xxxhdpi/round_launcher.png is excluded by !**/*.png
📒 Files selected for processing (16)
  • android/.gitignore (1 hunks)
  • android/app/build.gradle (1 hunks)
  • android/app/src/debug/AndroidManifest.xml (1 hunks)
  • android/app/src/main/AndroidManifest.xml (2 hunks)
  • android/app/src/main/kotlin/com/canopas/canopas_unity/MainActivity.kt (0 hunks)
  • android/app/src/main/kotlin/com/canopas/projectunity/MainActivity.kt (0 hunks)
  • android/app/src/main/kotlin/com/canopas/unity/MainActivity.kt (0 hunks)
  • android/app/src/main/kotlin/com/example/canopas_unity/MainActivity.kt (1 hunks)
  • android/app/src/main/res/values-night/styles.xml (1 hunks)
  • android/app/src/main/res/values/styles.xml (1 hunks)
  • android/app/src/profile/AndroidManifest.xml (1 hunks)
  • android/build.gradle (1 hunks)
  • android/gradle.properties (1 hunks)
  • android/gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • android/settings.gradle (1 hunks)
  • lib/ui/sign_in/bloc/sign_in_view_bloc.dart (1 hunks)
💤 Files with no reviewable changes (3)
  • android/app/src/main/kotlin/com/canopas/unity/MainActivity.kt
  • android/app/src/main/kotlin/com/canopas/canopas_unity/MainActivity.kt
  • android/app/src/main/kotlin/com/canopas/projectunity/MainActivity.kt
✅ Files skipped from review due to trivial changes (7)
  • android/app/src/main/res/values-night/styles.xml
  • android/app/src/main/res/values/styles.xml
  • android/.gitignore
  • android/build.gradle
  • android/app/src/debug/AndroidManifest.xml
  • android/app/src/main/kotlin/com/example/canopas_unity/MainActivity.kt
  • android/app/src/profile/AndroidManifest.xml
🚧 Files skipped from review as they are similar to previous changes (1)
  • android/gradle/wrapper/gradle-wrapper.properties
🔇 Additional comments (6)
android/app/build.gradle (1)

27-27: Critical: Overly restrictive minSdk will limit device compatibility

Setting minSdk = 34 will prevent the app from being installed on devices running Android 13 and below, which represents the majority of Android devices currently in use. Consider lowering the minSdk to support more devices while keeping targetSdk at 34 to utilize the latest features.

android/gradle.properties (1)

1-1: Verify build environments have sufficient memory for increased JVM arguments

The org.gradle.jvmargs have been updated to allocate more memory (-Xmx4G) and metaspace (-XX:MaxMetaspaceSize=2G), which can improve build performance. Ensure that all development and CI environments have enough physical memory to accommodate these settings without causing system instability or build failures due to insufficient memory.

android/settings.gradle (1)

21-22: Confirm removal of Google Services and Crashlytics plugins

It appears that the plugins for com.google.gms.google-services and com.google.firebase.crashlytics have been removed. If your app relies on Google services or Firebase Crashlytics for functionality like authentication, analytics, or crash reporting, this may impact those features. Please confirm that this removal is intentional and that alternative solutions are in place if needed.

android/app/src/main/AndroidManifest.xml (3)

1-1: Confirm removal of the package attribute in the manifest

The package attribute has been removed from the <manifest> tag. Since you're using the namespace property in build.gradle, this is acceptable in newer Android Gradle Plugin versions. Ensure that all references to the application package are correctly updated and that this change doesn't affect the app's behavior.


10-10: Verify the use of empty android:taskAffinity

Setting android:taskAffinity="" means this activity will not have a task affinity and can affect how tasks and activities are managed in the back stack. This can impact navigation and the behavior of your app when interacting with other apps. Ensure this is intended and tested across different scenarios.


34-44: LGTM: Addition of <queries> section for package visibility

Adding the <queries> element with intent filters for android.intent.action.PROCESS_TEXT is appropriate for Android 11 (API level 30) and above. This ensures that the app can query for activities that can process text, maintaining functionality in compliance with the package visibility changes introduced in Android 11.

android/app/build.gradle Show resolved Hide resolved
android/settings.gradle Show resolved Hide resolved
Comment on lines +42 to 44
} catch (e) {
emit(state.copyWith(
googleSignInLoading: false, error: firesbaseAuthError));
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Typo in variable name firesbaseAuthError

There's a typo in the variable firesbaseAuthError. It should be firebaseAuthError. This typo will cause a runtime error due to the undefined variable.

Apply this diff to fix the typo:

        } catch (e) {
          emit(state.copyWith(
              googleSignInLoading: false, error: firesbaseAuthError));
+             // Correct variable name
+             googleSignInLoading: false, error: firebaseAuthError));
        }

Committable suggestion skipped: line range outside the PR's diff.

@cp-sneha-s cp-sneha-s closed this Dec 3, 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.

1 participant