Open KrrishChheda04 opened 3 years ago
Same issue here, android app breaks when published with the plugin
Please help me if you find a solution
same issue, works fine in debug but when making release apk it crashes as soon the VLC widget is used
@silent-chan , @KrrishChheda04 , @fabianosanttana
Yep, It's the problem if you use > ver. 4.0. Cause, Plugin use v. vlc for android >= 3.3+ and current sdk v3.3+ has problem when build as release for android x86.
You should use 3.1+ sdk vlc into build.gradle
For example https://github.com/solid-software/flutter_vlc_player/blob/3.0.7/android/build.gradle
com.steiner.videolan:libvlc-android:3.1.7
EDIT: I just got this working with the latest version
Had some time to refactor my code to the newest flutter_vlc package.
Turns out all you need is the minifyEnabled false
& shrinkResources false
flags in your android/app/build.gradle file. (along with the internet permission tag & minsdk version as shown below) Did a flutter clean
first before re-installing the application.
Old comment: I just got a release working here is how i did it:
made new project with flutter create
in the new project removed the lib folder and pubspec.yaml file
copied over the lib folder, assets folder (if you have any assets) and the pubspec.yaml file from the existing project
changed vlc package version in my pubspec.yaml to flutter_vlc_player: ^3.0.7
(could be that you have to do a bit refactoring of your code after running pub get)
ran flutter pub get
edit android/app/build.gradle
set minSdkVersion to 17
& include in minifyEnabled false
and shrinkResources false
under buildTypes:
in android/app/src/main/AndroidManifest.xml include the internet permission <uses-permission android:name="android.permission.INTERNET" />
Make your apk as usual following the flutter tutorial on it, or if you want an unsigned APK just run these:
flutter build appbundle
flutter build apk --split-per-abi
flutter install
& select your device you want to install toThe app was crashing in release mode for me and instead of setting minifyEnabled
to false
I was able to solve the issue by adding -keep class org.videolan.libvlc.** { *; }
in the proguard file.
when I downloaded the example file from git their code works properly but when implemented the same code in my app the app straight away crashes with an error:
Running Gradle task 'assembleDebug'... √ Built build\app\outputs\flutter-apk\app-debug.apk. Installing build\app\outputs\flutter-apk\app.apk... Debug service listening on ws://127.0.0.1:54105/Id2yfbjio-E=/ws Syncing files to device SM M515F... D/Dialog ( 6596): mIsSamsungBasicInteraction = false D/Dialog ( 6596): mIsSamsungBasicInteraction = false, isMetaDataInActivity = false D/PhoneWindow( 6596): forceLight changed to true from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4274 com.android.internal.policy.DecorView.updateColorViews:1547 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3252 android.view.Window.setFlags:1153 com.android.internal.policy.PhoneWindow.generateLayout:2474 I/MultiWindowDecorSupport( 6596): [INFO] isPopOver = false I/MultiWindowDecorSupport( 6596): updateCaptionType >> DecorView@d8c1171[], isFloating: false, isApplication: false, hasWindowDecorCaption: false, hasWindowControllerCallback: false D/MultiWindowDecorSupport( 6596): setCaptionType = 0, DecorView = DecorView@d8c1171[] W/Gralloc3( 6596): allocator 3.x is not supported I/ViewRootImpl@9657a73MainActivity: setView = com.android.internal.policy.DecorView@d8c1171 TM=true MM=false E/AndroidRuntime( 6596): FATAL EXCEPTION: main E/AndroidRuntime( 6596): Process: com.example.video, PID: 6596 E/AndroidRuntime( 6596): java.lang.AbstractMethodError: abstract method "void io.flutter.plugin.platform.PlatformView.onFlutterViewAttached(android.view.View)" E/AndroidRuntime( 6596): at io.flutter.plugin.platform.VirtualDisplayController.onFlutterViewAttached(VirtualDisplayController.java:181) E/AndroidRuntime( 6596): at io.flutter.plugin.platform.PlatformViewsController$1.createVirtualDisplayForPlatformView(PlatformViewsController.java:233) E/AndroidRuntime( 6596): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:104) E/AndroidRuntime( 6596): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:59) E/AndroidRuntime( 6596): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) E/AndroidRuntime( 6596): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/AndroidRuntime( 6596): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:738) E/AndroidRuntime( 6596): at android.os.MessageQueue.nativePollOnce(Native Method) E/AndroidRuntime( 6596): at android.os.MessageQueue.next(MessageQueue.java:336) E/AndroidRuntime( 6596): at android.os.Looper.loop(Looper.java:197) E/AndroidRuntime( 6596): at android.app.ActivityThread.main(ActivityThread.java:8167) E/AndroidRuntime( 6596): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 6596): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) E/AndroidRuntime( 6596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) I/Process ( 6596): Sending signal. PID: 6596 SIG: 9 Lost connection to device.
Main.dart
import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter_vlc_player/flutter_vlc_player.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget { @override _MyAppState createState() => new _MyAppState(); }
class _MyAppState extends State {
@override
Widget build(BuildContext context) {
return new MaterialApp(home: MyAppScaffold());
}
}
class MyAppScaffold extends StatefulWidget { @override State createState() => MyAppScaffoldState();
}
class MyAppScaffoldState extends State {
String initUrl =
"http://samples.mplayerhq.hu/MPEG-4/embedded_subs/1Video_2Audio_2SUBs_timed_text_streams_.mp4";
Uint8List image;
VlcPlayerController _videoViewController;
var _scaffoldKey = new GlobalKey();
@override
void initState() {
_videoViewController = new VlcPlayerController(onInit: () {
_videoViewController.play();
});
super.initState();
}
@override Widget build(BuildContext context) { return new Scaffold( key: _scaffoldKey, appBar: new AppBar( title: const Text('Plugin example app'), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.camera), onPressed: _createCameraImage, ), body: Builder(builder: (context) { return Container( padding: EdgeInsets.all(10), child: ListView( shrinkWrap: true, children:[
SizedBox(
height: 250,
child: new VlcPlayer(
aspectRatio: 16 / 9,
url: initUrl,
isLocalMedia: false,
controller: _videoViewController,
),
),
Divider(height: 1),
image == null
? Container()
: Container(child: Image.memory(image)),
],
),
);
}),
);
}
@override void dispose() { _videoViewController.dispose(); super.dispose(); }
void _createCameraImage() async { Uint8List file = await _videoViewController.takeSnapshot(); setState(() { image = file; }); } }
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.video".>
<application android:label="video" android:icon="@mipmap/ic_launcher" android:usesCleartextTraffic="true"> <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize" tools:ignore="Instantiatable"> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
Please help me getting the solution. I desperately need to complete my app for project