Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter build api --release issue #99

Closed
thanhhuan1990 opened this issue Jul 1, 2019 · 16 comments · Fixed by #112
Closed

Flutter build api --release issue #99

thanhhuan1990 opened this issue Jul 1, 2019 · 16 comments · Fixed by #112
Labels
bug Something isn't working

Comments

@thanhhuan1990
Copy link

I have been gotten issue with retrieveCalendars when build release.

If I build project by code, device_calendar work well. But if I build release apk and then install by generated apk. this method cannot retrieveCalendars on device.

Please help me about this.

Thanks

@MaikuB
Copy link
Contributor

MaikuB commented Jul 5, 2019

We suspect this is related to the use of Proguard and we'll investigate

@MaikuB MaikuB added the bug Something isn't working label Jul 5, 2019
@thanhhuan1990
Copy link
Author

Thank for your response. I found problem myself but forgot update issue, it's really problem when release with Proguard, sorry for wasting your time.

@nickrandolph
Copy link
Contributor

@thanhhuan1990 can you elaborate more on what the issue is/way - if would help others if we can document what the issue was

@britannio
Copy link

britannio commented Aug 5, 2019

I had a similar issue due to Proguard. I fixed it by adding the following line to my Proguard file.
-keep class com.builttoroam.devicecalendar.** { *; }

@britannio
Copy link

Might be worth adding it to the readme.

@MaikuB
Copy link
Contributor

MaikuB commented Aug 5, 2019

Thanks @britannio, we planned to do so

@Iiridayn
Copy link

As an aside, turns out everyone is a proguard user now... This fixed my issue, even though I'm using a standard autogen flutter project with the latest release, etc. Finding it was a lucky stroke. Can how to create a proper proguard file be documented? I added the line from this issue to the file documented here https://flutter.dev/docs/deployment/android#step-1---configure-proguard .

@eliseyOzerov
Copy link

eliseyOzerov commented Mar 17, 2020

This solution worked for me for the Android build, what about the iOS? Because this bug is happening to my app on iOS as well.

@chuckinSpace
Copy link

chuckinSpace commented Apr 11, 2020

Where is this line supposed to go exactly? I know it says on the proguard file but, according to the docs it says it should be there in the project auto-generated, but in my case is not, do I suppose to create it?

@britannio
Copy link

Where is this line supposed to go exactly? I know it says on the proguard file but, according to the docs it says it should be there in the project auto-generated, but in my case is not, do I suppose to create it?

android/app/proguard-rules.pro
Mine looks like this:

#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }

# You might not be using firebase
# -keep class com.google.firebase.** { *; }
-keep class com.builttoroam.devicecalendar.** { *; }

then in android/app/build.gradle add the following line to buildTypes { release {}}
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

I also use minifyEnabled true and shrinkResources true in the same place.

Finally under android/gradle.properties I have android.enableR8=true, R8 still respects your proguard rules.

@Ananthan1996
Copy link

Now I can retrieve calendars in release mode by adding proguard. But for release mode deletion of event is not working.Can anyone help me in this case.I have an important feature to release.

@technoAri
Copy link

@britannio android/app/proguard-rules.pro - this would be inside the flutter app's android/app or inside the plugin's?

@britannio
Copy link

@britannio android/app/proguard-rules.pro - this would be inside the flutter app's android/app or inside the plugin's?

Inside your Flutter app.

@jurgenramirez
Copy link

I did not have the pro guard files before and I am creating the apk as follows
flutter build apk --release
I have added the solution that they mention but it does not work, it seems that when I generate the apk it does not take the proguard

in the gradle.properties located in android/gradle.properties add this line

android.enableR8=true

in android/app/build.gradle file add
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

and add the file
android/app/proguard-rules.pro

#Flutter Wrapper
-keep class io.flutter.app.** { ; }
-keep class io.flutter.plugin.
* { ; }
-keep class io.flutter.util.
* { ; }
-keep class io.flutter.view.
* { ; }
-keep class io.flutter.
* { ; }
-keep class io.flutter.plugins.
* { *; }

You might not be using firebase

-keep class com.google.firebase.** { ; }
-keep class com.builttoroam.devicecalendar.
* { *; }

@fraboniface
Copy link

As someone who just spent a full day on this thinking the problem came from somewhere else, you can follow the steps from @jurgenramirez but do use the proguard file of @britannio, with the endings in .** { *; }.

@rajatency
Copy link

Where is this line supposed to go exactly? I know it says on the proguard file but, according to the docs it says it should be there in the project auto-generated, but in my case is not, do I suppose to create it?

android/app/proguard-rules.pro Mine looks like this:

#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }

# You might not be using firebase
# -keep class com.google.firebase.** { *; }
-keep class com.builttoroam.devicecalendar.** { *; }

then in android/app/build.gradle add the following line to buildTypes { release {}} proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

I also use minifyEnabled true and shrinkResources true in the same place.

Finally under android/gradle.properties I have android.enableR8=true, R8 still respects your proguard rules.

Works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.