endmr11 / ed_screen_recorder

Screen recorder plugin for Flutter. Supports IOS and Android devices.
MIT License
26 stars 35 forks source link

Android error and app crash #21

Closed jaish702 closed 2 years ago

jaish702 commented 2 years ago

hi once again I am having the same problem. but when as you say in the above statement I have done the the same thing it's work but when I created the new project then in my existing project it's showing the same error so for helping you to understand the problem .this is my code :- import 'dart:io'; import 'package:ed_screen_recorder/ed_screen_recorder.dart'; import 'package:firebase_storage/firebase_storage.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart';

class Textspeech extends StatefulWidget { const Textspeech({super.key});

@OverRide State createState() => _TextspeechState(); }

class _TextspeechState extends State { File? file; EdScreenRecorder? screenRecorder; uploadvideo() async { final ref = FirebaseStorage.instance.ref().child("dd"); UploadTask uploadTask = ref.putFile(file!); final snapshot = await uploadTask.whenComplete(() {}); final urldownload = await snapshot.ref.getDownloadURL(); // ignore: avoid_print print("download video $urldownload"); }

Future pauseRecord() async { try { await screenRecorder?.pauseRecord(); } on PlatformException { kDebugMode ? debugPrint("Error: An error occurred while pause recording.") : null; } }

Future resumeRecord() async { try { await screenRecorder?.resumeRecord(); } on PlatformException { kDebugMode ? debugPrint("Error: An error occurred while resume recording.") : null; } }

@OverRide void initState() { super.initState(); screenRecorder = EdScreenRecorder(); }

@OverRide Widget build(BuildContext context) { return Scaffold( body: Container( height: double.infinity, width: double.infinity, color: Colors.black87, child: Column( children: [ ElevatedButton( onPressed: () async { try { await screenRecorder?.startRecordScreen( fileName: 'jaish', audioEnable: true, dirPathToSave: uploadvideo()); } on PlatformException { kDebugMode ? debugPrint( "Error: An error occurred while starting the recording!") : null; } }, child: const Text("Start video")), ElevatedButton( onPressed: () => resumeRecord(), child: const Text('RESUME RECORD')), ElevatedButton( onPressed: () => pauseRecord(), child: const Text('PAUSE RECORD')), ElevatedButton( onPressed: () async { try { await screenRecorder?.stopRecord(); await screenRecorder?.fileWatcherStart(file!); final ref = FirebaseStorage.instance.ref().child("dd"); UploadTask uploadTask = ref.putFile(file!); final snapshot = await uploadTask.whenComplete(() {}); final urldownload = await snapshot.ref.getDownloadURL(); // ignore: avoid_print print("download video $urldownload"); } on PlatformException { kDebugMode ? debugPrint( "Error: An error occurred while stopping recording.") : null; } }, child: const Text("Stop video")) ], ), ), ); } } this is my build.gradel :- 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 plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.google.gms.google-services'

android { compileSdkVersion 31

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/build/application-id.html). applicationId "com.example.screenre123" minSdkVersion 23 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true }

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 'androidx.appcompat:appcompat:1.4.1' implementation "androidx.multidex:multidex:2.0.1" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation platform('com.google.firebase:firebase-bom:30.0.0') implementation 'com.google.firebase:firebase-analytics' implementation 'com.github.HBiSoft:HBRecorder:2.0.4' }

and one more thing is that when I had eyes on you code I found that you said in readme that implementation 'com.github.HBiSoft:HBRecorder:2.0.3' but you use implementation 'com.github.HBiSoft:HBRecorder:2.0.4' I am getting same problem from both.

jaish702 commented 2 years ago

D:\src\flutter.pub-cache\hosted\pub.dartlang.org\ed_screen_recorder-0.0.11\android\src\main\java\com\ed_screen_recorder\ed_screen_recorder\EdScreenRecorderPlugin.java:35: warning: [deprecation] Registrar in PluginRegistry has been deprecated import io.flutter.plugin.common.PluginRegistry.Registrar; ^ D:\src\flutter.pub-cache\hosted\pub.dartlang.org\ed_screen_recorder-0.0.11\android\src\main\java\com\ed_screen_recorder\ed_screen_recorder\EdScreenRecorderPlugin.java:63: warning: [deprecation] Registrar in PluginRegistry has been deprecated public static void registerWith(Registrar registrar) { ^ 2 warnings Running Gradle task 'assembleDebug'...