FAILURE: сборка не удалась с исключением.
- Что пошло не так:
Произошла проблема при настройке проекта ':razorpay_flutter'.
Пространство имен не указано. Укажите пространство имен в файле сборки модуля. Информацию о настройке пространства имен см. на странице https://d.android.com/r/tools/upgrade-a ... -namespace.
If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-a ... -assistant for general information about using the AGP Upgrade Assistant.
- Попробуйте:
Запустите с параметром --info или --debug, чтобы получить больше результатов журнала.
Запустите с --scan, чтобы получить полную информацию.
- Получите дополнительную помощь по адресу https://help.gradle.org
Исключение: ошибка сборки задачи GradleDebug с кодом завершения 1
файл, в котором я использую плагин razorpay
import 'dart:convert';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:fluttertoast/fluttertoast.dart';
import 'package:razorpay_flutter/razorpay_flutter.dart';
class BillingDialogBox extends StatefulWidget {
BillingDialogBox({
Key? key,
required this.providerName,
required this.categoryName,
required this.charges,
required this.selectedDate,
required this.seekername,
}) : super(key: key);
final String providerName;
final String categoryName;
final String charges;
final DateTime? selectedDate;
final String seekername;
@override
State createState() => _BillingDialogBoxState();
}
class _BillingDialogBoxState extends State {
late String providerName;
late String categoryName;
late double charges;
late DateTime? selectedDate;
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;
late String seekername;
late Razorpay _razorpay;
bool _isPaymentProcessing = false;
@override
void initState() {
super.initState();
_razorpay = Razorpay();
_razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, handlePaymentSuccess);
_razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, handlePaymentError);
providerName = widget.providerName;
categoryName = widget.categoryName;
charges = double.parse(widget.charges);
selectedDate = widget.selectedDate;
seekername = widget.seekername;
}
@override
void dispose() {
super.dispose();
_razorpay.clear();
}
void handlePaymentError(PaymentFailureResponse response) {
Fluttertoast.showToast(msg: "Error while payment ${response.code}");
setState(() {
_isPaymentProcessing = false;
});
}
void handlePaymentSuccess(PaymentSuccessResponse response) async {
Fluttertoast.showToast(msg: "Payment Successful ${response.paymentId}");
final String uid = FirebaseAuth.instance.currentUser!.uid;
await FirebaseFirestore.instance.collection('Scheduling').add({
"UID": uid,
'provider_name': providerName,
'date': selectedDate,
'status': 'pending',
'amount': charges,
'seeker_name': seekername,
});
storePaymentDetails(response.paymentId!);
sendNotification(providerName);
setState(() {
_isPaymentProcessing = false;
});
}
Future storePaymentDetails(String paymentID) async {
await FirebaseFirestore.instance.collection('Payment').add({
"payment ID": paymentID,
'provider_name': providerName,
'date': selectedDate,
'amount': charges,
'seeker_name': seekername,
});
}
void makePayment() async {
setState(() {
_isPaymentProcessing = true;
});
var options = {
'key': 'YOUR_RAZORPAY_KEY_ID', // Replace with your Razorpay Key ID
'amount': (charges * 100).toInt(),
'name': seekername,
'description': 'Payment for $categoryName Service',
'prefill': {'email': 'example@example.com'},
'external': {
'wallets': ['paytm']
}
};
_razorpay.open(options);
}
@override
Widget build(BuildContext context) {
double GST = charges * 0.05;
double total = charges + GST + GST;
return Container(
height: MediaQuery.of(context).size.height * 0.8,
padding: const EdgeInsets.fromLTRB(16, 48, 16, 16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Billing Info",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
const Divider(color: Colors.black),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text("Provider Name: $providerName"),
const Spacer(),
Text("Service Name: $categoryName"),
],
),
const Divider(color: Colors.black),
const SizedBox(height: 20),
Row(
children: [
const Text("Service Charges:"),
const Spacer(),
Text("₹ $charges"),
],
),
const SizedBox(height: 10),
const Text("GST ", style: TextStyle(fontWeight: FontWeight.bold)),
Row(
children: [
const Text("CGST 5%:"),
const Spacer(),
Text("₹ $GST"),
],
),
const SizedBox(height: 10),
Row(
children: [
const Text("SGST 5%:"),
const Spacer(),
Text("₹ $GST"),
],
),
const Divider(color: Colors.black),
Row(
children: [
const Text("Total Payable Amount:"),
const Spacer(),
Text("₹ $total"),
],
),
const Divider(color: Colors.black),
const SizedBox(height: 20),
Row(
children: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Cancel"),
),
ElevatedButton(
onPressed: _isPaymentProcessing ? null : makePayment,
child: _isPaymentProcessing
? CircularProgressIndicator()
: const Text('Make Payment'),
),
],
),
],
),
);
}
void sendNotification(String providerName) {
FirebaseFirestore.instance
.collection('tokens')
.where('name', isEqualTo: providerName)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
if (doc.exists) {
String providerToken = doc['token'];
RemoteMessage notificationMessage = RemoteMessage(
data: {
'title': 'New Service Request',
'body': 'You have a new service request from $seekername.',
},
);
sendNotificationToServer(providerToken, notificationMessage);
}
});
});
}
void sendNotificationToServer(
String providerToken, RemoteMessage notificationMessage) {
http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
body: jsonEncode({
'to': providerToken,
'data': notificationMessage.data,
'notification': notificationMessage.notification,
}),
headers: {
'Content-Type': 'application/json',
'Authorization':
'AAAARVTHu4M:APA91bHTwGD9scs5f-WhOX0D-a4NX-Vo4-1T8rahNQnwhF9UJJ_RBssouK4ChS-p7r1TmgKSwjHfPgCx8cIjgpTtRS32m03TTW83XJvGnr8gjQVDPtFkEnBwgat6xCrLjXr4G8wRCy1B'
},
);
}
}
android/build.gradle:
buildscript {
ext.kotlin_version = '1.9.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
classpath 'com.google.gms:google-services:4.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
android/app/build.gradle:
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id 'com.google.gms.google-services'
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.example.local_service_provider"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/bu ... on-id.html).
applicationId "com.example.local_service_provider"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/and ... figuration.
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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 {
implementation platform('com.google.firebase:firebase-bom:32.7.2')
implementation("com.google.firebase:firebase-auth")
}
AndroidManifest.xml:
pubspec.yaml:
name: local_service_provider
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/arc ... nKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: '>=3.1.5
Подробнее здесь: https://stackoverflow.com/questions/780 ... ng-a-error
Мобильная версия