humazed / google_map_location_picker

🌍 Map location picker component for flutter Based on google_maps_flutter
Apache License 2.0
206 stars 309 forks source link

Flutter location picker crashes on real device on release apk #137

Open AzarovDN opened 3 years ago

AzarovDN commented 3 years ago

The application works when launched from Visual Studio. But when I upload it to Google Play for testing, it crashes the moment I call the showLocationPicker function. LocationPicker starts, asks for permission to access the location, then crashes.

main.dart

void main() async {
      try {
        WidgetsFlutterBinding.ensureInitialized();
        SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
        await Firebase.initializeApp();
        Get.put(StateController());
        await GetStorage.init();
        await DB.init();
      } catch (err) {
        print('err $err');
      }
      runApp(MyApp());
    }

    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return GetMaterialApp(
          initialBinding: AuthBinding(),
          debugShowCheckedModeBanner: false,
          localizationsDelegates: const [
            location_picker.S.delegate,
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
          ],
          supportedLocales: const <Locale>[
            Locale('en', ''),
            Locale('ru', ''),
          ],
          theme: ...

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="my.name.com">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="com.android.vending.BILLING" />

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-feature android:name="android.hardware.location.network" android:required="false" />
    <uses-feature android:name="android.hardware.location.gps" android:required="false"  />

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="Приложение"
        android:icon="@mipmap/ic_launcher">
        <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="My_Key"/>

The button, by pressing which, I call the Location Picker

floatingActionButton: FloatingActionButton(onPressed: () async {
        final apiKeyIos = 'apiKeyIos';
        final apiKeyAndroid = 'apiKeyAndroid';
        try {
          showLocationPicker(
            context,
            Platform.isIOS ? apiKeyIos : apiKeyAndroid,
            initialCenter: LatLng(53.59575326915039, 142.9515826329589),
            initialZoom: 5,
            myLocationButtonEnabled: true,
            countries: ['RU'],
            language: 'ru',
            requiredGPS: true,
          );
        } catch (e) {
          Get.defaultDialog(
            title: 'Ошибка',
            middleText: e.toString(),
          );
        }
      }),
humazed commented 3 years ago

could you provide a minimum reproducible example app?

AzarovDN commented 3 years ago

Here is my code https://github.com/AzarovDN/location_picker I'm deleted all unnecessary code, API_KEY and google-services.json.

humazed commented 3 years ago

Thanks will check it. one more question are you able to reproduce it with the sample app?

also as I understand the only reproduction steps are running.

flutter build apk --release
flutter install

please correct me if I'm wrong.

AzarovDN commented 3 years ago

Yes! I can reproduce this with a sample application.

My step: flutter build appbundle

And then I put the app on Google Play for internal testing. And there I catch this error. If you give me your email, I can add you to the testers so you can see how it works. My telegram @Azarov_DN.

I tried running flutter build apk --release And caught the error

flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split

FAILURE: Build failed with an exception.                                

* What went wrong:                                                      
Execution failed for task ':app:lintVitalRelease'.                      
> Could not resolve all artifacts for configuration ':app:profileRuntimeClasspath'.
   > Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: /Users/azarovdn/Desktop/Tornado Flutter 2/tornado/build/app/intermediates/flutter/profile/libs.jar.
         > Transform's input file does not exist: /Users/azarovdn/Desktop/Tornado Flutter 2/tornado/build/app/intermediates/flutter/profile/libs.jar. (See https://issuetracker.google.com/issues/158753935)

* Try:                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org                              

BUILD FAILED in 5s                                                      
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                       6,7s
Gradle task assembleRelease failed with exit code 1

I have not yet understood what the problem is.

usmannaushahi commented 3 years ago

Not working on release mode, but working on debug. Did you figure out the issue?

AzarovDN commented 3 years ago

No

usmannaushahi commented 3 years ago

Update the below code inside buildTypes with yours. /android/app/build.gradle

buildTypes { release { shrinkResources false minifyEnabled false signingConfig signingConfigs.debug } }

AzarovDN commented 3 years ago

Thank you!