所以我嘗試使用flutter_downloader包使用給定的URL下載檔案下面是我的實作,
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterDownloader.initialize(
debug: true // optional: set false to disable printing logs to console
);
runApp(new MaterialApp(
home: new MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_State createState() => new _State();
}
class _State extends State<MyApp> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: Text('Template Code'),backgroundColor:
Colors.green,),
body: Container(
padding: EdgeInsets.all(50.0),
child: Center(child:Column(
children: <Widget> [
Text('Hello World'),
RaisedButton(onPressed: () async {
final status = await Permission.storage.request();
if (status.isGranted) {
final externalDir = await getExternalStorageDirectory();
final id = await FlutterDownloader.enqueue(
url:
"https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4",
savedDir: externalDir!.path,
fileName: "download",
showNotification: true,
openFileFromNotification: true,
);
} else {
print("Permission denied");
}
}),
],
)),
),
);
}
}
當我在我的模擬器上運行它時,我得到了這個例外
FAILURE: Build failed with an exception.
- 出了什么問題:任務“:app:generateDebugBuildConfig”執行失敗。
無法計算任務“:app:generateDebugBuildConfig”屬性“buildConfigPackageName”的值。無法查詢屬性“packageName”的值。> org.xml.sax.SAXParseException;systemId:檔案:/C:/Users/HP/Desktop/OWASLO/care_giver_app/android/app/src/main/AndroidManifest.xml;行號:25;列號:31;與元素型別“provider”關聯的屬性“tools:node”的前綴“tools”未系結。
嘗試:使用 --stacktrace 選項運行以獲取堆疊跟蹤。使用 --info 或 --debug 選項運行以獲得更多日志輸出。運行 --scan 以獲得完整的見解。
在https://help.gradle.org獲得更多幫助
請幫忙!!!
uj5u.com熱心網友回復:
簽出這個問題執行緒:https ://github.com/flutter/flutter/issues/63114
基本上,您可以嘗試的步驟是:
- 洗掉 Gradle 快取
%USER_HOME%\.gradle/caches/(它會再次重新下載 Gradle) - 跑
flutter clean - 跑
flutter pub get
uj5u.com熱心網友回復:
清單檔案有問題
缺少這一行: xmlns:tools="http://schemas.android.com/tools"
在manifest標簽中
它應該如下所示。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="app package name">
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/418538.html
標籤:
下一篇:引導日期選擇器固定在頁面頂部
