Search code examples
androidflutterflutter-dependenciesandroid-sdk-2.3android-sdk-manager

flutter build apk installing platform-tools repeatedly


I have installed flutter and android-SDK ( without android studio ) on windows-10. Installation completed successfully and everything is fine and no errors in web but when I run flutter build apk it throws some warnings


 Building with sound null safety

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Checking the license for package Android SDK Platform-Tools in C:\Users\ItzJVS\AppData\Local\android\cmdline-tools\tools\licenses
License for package Android SDK Platform-Tools accepted.
Preparing "Install Android SDK Platform-Tools (revision: 31.0.3)".
Warning: Package "com.android.repository.impl.generated.v1.RemotePackage@5f56b0a9" (platform-tools) should be installed in
"C:\Users\ItzJVS\AppData\Local\android\cmdline-tools\tools\platform-tools" but
it already exists.
Installing in "C:\Users\ItzJVS\AppData\Local\android\cmdline-tools\tools\platform-tools-2" instead.
Running Gradle task 'assembleRelease'...

and it starts downloading platform-tools , build-tools and emulator ( if already exist still it going to download again and again like platform-tools-2 , build-tools-2 and emulator-2 )

my flutter doctor -v is

[√] Flutter (Channel stable, 2.5.0, on Microsoft Windows [Version 10.0.17763.195], locale en-IN)
    • Flutter version 2.5.0 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cc385b4b8 (10 days ago), 2021-09-07 23:01:49 -0700
    • Engine revision f0826da7ef
    • Dart version 2.14.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\ItzJVS\AppData\Local\android\cmdline-tools\tools
    • Platform android-30, build-tools 29.0.2
    • ANDROID_HOME = C:\Users\ItzJVS\AppData\Local\android
    • Java binary at: C:\Program Files\Java\jdk1.8.0_301\bin\java.exe
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] VS Code (version 1.60.1)
    • VS Code at C:\Users\ItzJVS\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.26.0

[√] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82

! Doctor found issues in 1 category.

I'm not getting what I'm doing wrong can some one help me to resolve this .. ThankYou.. 


Solution

  • Apparently you just need to setup android sdk files structure correctly. i made this follow video showing the steps to follow. The Video

    or follow this steps:

    1. install flutter sdk and the java jdk and add theme to environment variables of your system.

    2. Head to https://developer.android.com/studio#command-tools and download the Command line tools only & Extract zip file to c:\ANDROID-SDK add it to environment variables 'ANDROID_SDK_ROOT' : "c:\ANDROID-SDK"

    3. Now open the following path in CMD "C:\ANDROID-SDK\cmdline-tools\bin"

    4. Run the command sdkmanager.bat "cmdline-tools;latest" --sdk_root=../../

    5. Now add this to your environment variables path "C:\ANDROID-SDK\cmdline-tools\latest\bin"

    6. next open CMD and install build-tools "sdkmanager.bat "build-tools;30.0.3" "

    7. then platforms sdkmanager.bat "platforms;android-31"

    8. now run flutter config --android-sdk %ANDROID_SDK_ROOT%

    9. run flutter doctor --android-licenses and accept the licenses.

    10. Now go to your project run flutter build apk

    hope this will help anyone having the same issue