Caramel
Caramel

Reputation: 121

flutter release app different with the debug mode

So i making an app that use a Camera, at the debug mode everything works fine, the camera could open just fine, but when i convert it to an APK the camera isnt working.

Here's the code:

Future<Null> _pickImageCam() async {
    final pickedImage =
    await ImagePicker().getImage(source: ImageSource.camera);
    imageFile = pickedImage != null ? File(pickedImage.path) : null;
    if (imageFile != null) {
      setState(() {
        state = AppState.picked;
      });
    }
  }

I Used the Future Class using a list tile

ListTile(
          leading: Icon(Icons.camera_alt),
          title: Text('Camera'),
          onTap: () {
            if (state == AppState.free)
              _pickImageCam().then((value) => _cropImage());
            Navigator.pop(context);
          },
        ),

Upvotes: 0

Views: 162

Answers (2)

Caramel
Caramel

Reputation: 121

I just figure it out, Just add Permission on all AndoidManifest.xml, (Android/app/src/(debug,main,profile)).

here's where to add on (debug,profile).

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.~~~.~~~">
    <!-- Flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
//new
    <uses-permission android:name="android.permission.CAMERA" />
//new
</manifest>

on main AndroidManifest.xml

...
<meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
//new
    <uses-permission android:name="android.permission.CAMERA" />
//new
</manifest>

Upvotes: 0

akram abdullah
akram abdullah

Reputation: 164

Step 1:Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file. Step 2 add permisstion in menifest file

Upvotes: 1

Related Questions