aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.33k stars 248 forks source link

A problem occurred configuring project ':amplify_auth_cognito_android' #1689

Closed jheimes-silveira closed 2 years ago

jheimes-silveira commented 2 years ago

Description

i'm always getting this error when trying to compile

Launching lib/main_dev.dart on Android SDK built for x86 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':amplify_auth_cognito_android'.
> this and base files have different roots: D:\projetos\condoconta\flutter-mobile-condoconta\flut_base_app_condoconta_syndic\build\amplify_auth_cognito_android and C:\Users\jheime\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\amplify_auth_cognito_android-0.5.1\android.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Exception: Gradle task assembleDevDebug failed with exit code 1
Exited (sigterm)

Categories

Steps to Reproduce

i'm always getting this error when trying to compile

Screenshots

Captura de tela 2022-06-06 093509

Platforms

Android Device/Emulator API Level

API 32+

Environment

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [versao 10.0.22000.708], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0)
[√] Android Studio (version 2021.1)
[√] VS Code (version 1.67.2)
[√] Connected device (4 available)
[√] HTTP Host Availability

• No issues found!

Dependencies

amplify_flutter: 0.5.1
  amplify_auth_cognito: 0.5.1
  amplify_core: 0.5.1
  amplify_auth_cognito_android: 0.5.1
  carousel_slider: 4.1.1
  camera: 0.9.5+1
  cupertino_icons: 1.0.4
  cached_network_image: 3.2.1
  cpf_cnpj_validator: 2.0.0
  dotted_border: 2.0.0+2
  device_info_plus: 3.2.3
  email_validator: 2.0.1
  enum_to_string: 2.0.1
  flutter_modular: 5.0.2
  file_picker: 4.5.1
  flutter_mobx: 2.0.6+1
  flutter_svg: 1.0.3
  flutter_keyboard_visibility: 5.2.0
  flutter_cache_manager: 3.3.0
  flutter_spinkit: 5.1.0
  fluttertoast: 8.0.9
  flutter_udid: 2.0.0
  barcode_scanner_kit: 1.0.1
  image_picker: 0.8.5
  intl: 0.17.0
  just_the_tooltip: 0.0.11+2
  jiffy: 5.0.0
  localization: 2.1.0
  logger: 1.1.0
  mocktail: 0.3.0
  mobx: 2.0.7
  mask_text_input_formatter: 2.3.0
  easy_mask: 2.0.1
  native_pdf_view: 6.0.0+1
  notification_permissions: 0.6.1
  path_provider: 2.0.9
  package_info_plus: 1.4.2
  pin_code_fields: 7.4.0
  recase: 4.0.0
  screenshot: 1.2.3
  sticky_and_expandable_list: 1.0.3 
  share_plus: 3.0.5
  shared_preferences: 2.0.13
  shimmer: 2.0.0
  timer_count_down: 2.2.1
  uuid: 3.0.5
  url_launcher: 6.1.2
  dio: 4.0.6
  flutter_image_compress: 1.1.0
  syncfusion_flutter_pdfviewer: 20.1.56-beta
  syncfusion_flutter_pdf: 20.1.56-beta
  crypto: 3.0.1
  dropdown_search: 3.0.1
  webviewx:

Device

Pixel 3a XL API 30 (Android-x86 emulator)

OS

Android 11

CLI Version

7.6.21

Additional Context

No response

Jordan-Nelson commented 2 years ago

Hi @jheimes-silveira - Thanks for taking the time to open the issue and include the info you have provided. Can you share your /android/build.gradle file?

jheimes-silveira commented 2 years ago
buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
    }
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.1"
            }
            if (details.requested.group == 'androidx.core'
                    && !details.requested.name.contains('androidx') ) {
                details.useVersion "1.0.1"
            }
        }
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
jheimes-silveira commented 2 years ago

a temporary solution I found was to redirect an environment variable: PUB_CACHE= point to the same root directory

this temporarily solved me

Jordan-Nelson commented 2 years ago

Thanks @jheimes-silveira. I am not sure if this is related to any in Amplify, but I will see if I can reproduce. I may follow up with more info as I attempt to reproduce this.

There have been similar issues (https://github.com/flutter/flutter/issues/88234) opened up in the flutter repo, but it looks like fixes were added in flutter 3.0.0 to resolve them.

tree1891 commented 2 years ago

Same issue with com.android.tools.build:gradle:7.x, but not gradle 4.x.

Isaac-dot commented 2 years ago

@jheimes-silveira > a temporary solution I found was to redirect an environment variable: PUB_CACHE= point to the same root directory

this temporarily solved i met the same error could you describe your solution in detail

Jordan-Nelson commented 2 years ago

Hey everyone - Apologies for the delay in an update. I just worked with a customer who reported this same issue on our Discord server. They were able to work around it by moving flutter and the project to the same drive. They only experienced this when Flutter was installed on their C drive and the project was on their F drive. It seems that this is only an issue on Windows when flutter is located on a different drive that the project that is being run. I am not sure if there is anything that we can do within Amplify to resolve this. It seems like this may be a limitation with Flutter and Windows.

If anyone is having this issue that is either not using Windows, or is using Windows but has confirmed that flutter is located on the same drive as the project that they are building, can you please share what OS you are seeing this on?

Isaac-dot commented 2 years ago

OS : Window sdk.dir=C:/Users/52304/AppData/Local/Android/Sdk flutter.sdk=D:\Flutter\scr\flutter

this is my OS and local.properties path. Is it possible to occure the error? project location: D:\GITup\BILJ\donewitharq

Isaac-dot commented 2 years ago

a temporary solution I found was to redirect an environment variable: PUB_CACHE= point to the same root directory

this temporarily solved me

thank you for providing the solution, but could you share the detail step that you solve this error

Jordan-Nelson commented 2 years ago

@Isaac-dot - What drive is the project you are trying to build located on?

Isaac-dot commented 2 years ago

@Isaac-dot - What drive is the project you are trying to build located on?

thank you for reply the project is located on D drive flutter is located on D drive as well

Jordan-Nelson commented 2 years ago

@Isaac-dot - Can you share the full exception you are seeing? Thanks

Isaac-dot commented 2 years ago

FAILURE: Build failed with an exception.

BUILD FAILED in 5s Exception: Gradle task assembleDebug failed with exit code 1 屏幕截图 2022-08-23 112003

Jordan-Nelson commented 2 years ago

@Isaac-dot - it looks like your pub cache is still located on your C drive. Can you try updating this to be the D drive since that is where you have flutter installed and where the app is located? See instructions under PUB_CACHE here: https://dart.dev/tools/pub/environment-variables

Isaac-dot commented 2 years ago

@Isaac-dot - it looks like your pub cache is still located on your C drive. Can you try updating this to be the D drive since that is where you have flutter installed and where the app is located? See instructions under PUB_CACHE here: https://dart.dev/tools/pub/environment-variables

thank you, i understand, but how can i change the pub cache location, i have been to the link that you provide, but i dont knnow how to set a PUB_CACHE environment variable. could you explain that thank you so much

Jordan-Nelson commented 2 years ago

It will vary depending on what version of windows you are on. Here is a pretty comprehensive guide on environment variables on Windows.

Isaac-dot commented 2 years ago

@Jordan-Nelson Sorry to bother you alot, i am new to flutter dart and AMS i am using windows 10. I create the PUB_CHACHE environment variables image but how to redirect to it

Jordan-Nelson commented 2 years ago

I believe all you need to do is set that environment variable. Pub should use that to determine where to download dependencies. Try running the project again and see if you get the same error.

Isaac-dot commented 2 years ago

image same error, the error shows that the environment variable still point tp the old one. i restart my laptop already. well do i need to delete the old environment variable path( the one in C drive )?

Jordan-Nelson commented 2 years ago

If you see that there is one set referencing the C drive, yes.

You can run 'echo %PUB_CACHE%' from command prompt to see if the var is set.

Isaac-dot commented 2 years ago

image i delete the old one, it shows me other errors like system cannot find the command path. how should i change the import in the main.dart file image

Jordan-Nelson commented 2 years ago

You will likely need to run 'flutter clean' and 'flutter pub get' to reinstall dependencies now that you have changed the location that they are downloaded.

You might also need to run 'flutter pub cache clean' or 'flutter pub cache repair'. You can read more about those here - https://dart.dev/tools/pub/cmd/pub-cache#reinstalling-all-packages-in-the-system-cache

Jordan-Nelson commented 2 years ago

Hey everyone - Apologies for the delay in an update. I just worked with a customer who reported this same issue on our Discord server. They were able to work around it by moving flutter and the project to the same drive. They only experienced this when Flutter was installed on their C drive and the project was on their F drive. It seems that this is only an issue on Windows when flutter is located on a different drive that the project that is being run. I am not sure if there is anything that we can do within Amplify to resolve this. It seems like this may be a limitation with Flutter and Windows.

If anyone is having this issue that is either not using Windows, or is using Windows but has confirmed that flutter is located on the same drive as the project that they are building, can you please share what OS you are seeing this on?

I will leave this issue open for a bit longer to see if anyone is having this issue that is unable to resolve it by updating the directory of their app, flutter, and/or pub. After that I will likely close this out since it doesn't appear to be specific to Amplify.

akmalDev98 commented 2 years ago

I faced the same issues. I found out that the problem is on the Flutter SDK. You may try to download new Flutter SDK and replace with the current one. It works for me.

Jordan-Nelson commented 2 years ago

I am going to close this issue since this appears to be a limitation with Windows/Flutter/Android, and not specific to Amplify. For anyone facing this issues, see this comment: https://github.com/aws-amplify/amplify-flutter/issues/1689#issuecomment-1221062758

musabibnusiraj commented 1 year ago

I faced the same issue. I moved the app to the same flutter directory & build. It works for me.

rocosrex commented 1 year ago

Thank you @Jordan-Nelson . I faced the same issue. I set pub_cache variable and my issue is solved.