0
votes

I tried to add flute_music_player: ^0.0.6 to my flutter project dependencies

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  flute_music_player: ^0.0.6

and get below error after project run.

Could not resolve com.android.support:support-v4:27.1.0. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/support-v4/27.1.0/support-v4-27.1.0.pom'.

Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/support-v4/27.1.0/support-v4-27.1.0.pom'. sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

build.gradle (path => project_dir/android/build.gradle)

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

android app build.gradle (path => project_dir/android/app/build.gradle)

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 26

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.child_controller"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

and below is my dependency widget source code

import "package:flute_music_player/flute_music_player.dart";
import "package:flutter/material.dart";

class MyMusicList extends StatefulWidget {
  @override
  _MyMusicListState createState() => _MyMusicListState();
}

class _MyMusicListState extends State<MyMusicList> {

  List<dynamic> _songs;

  @override
  void initState() {
    super.initState();
    initMusicPlayer();
  }

  void initMusicPlayer() async {
    var songs = await MusicFinder.allSongs();
    songs = List.from(songs);

    setState(() {
      _songs = songs;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Tap the Song to Play"),
      ),
      body: Container(
        child: ListView.builder(
          itemCount: (_songs != null) ? _songs.length: 0,
          itemBuilder: (context, int index) {
            return ListTile(
              leading: CircleAvatar(
                child: Text(_songs[index].title[0]),
              ),
              title: Text(_songs[index].title),
            );
          },
        ),
      ),
    );
  }
}

I am pretty sure that my Android Studio IDE version is updated, and all support repositories, dependencies and APIs are installed.

1

1 Answers

0
votes

I tried and follow below steps to resolve this issue in Windows 10.

Firewall Permission

Allow apps to communicate through Windows Defender Firewall.

Added Android Studio both executors studio.exe and studio64.exe to Firewall (inside C:\Program Files\Android\Android Studio\bin)

Windows Defender Firewall with Advanced Security on Local Computer

Allowed the blocked network connection Java(TM) Platform SE binary under Inbound & Outbound Rules

Android Studio IDE Activities

In Terminal executed command flutter run --release to signing with the debug keys for development.

flutter clean

flutter pub get

File - Save All 

File - Sync with File System 

File - Invalidate Caches / Restart - Invalidate and Restart

// and again after IDE Restart

File - Sync with File System

and so finally, my app executed successfully.