Mapbox's LocationLayerPlugin not updating location when Proguard is enabled - android

I'm using Mapbox's LocationLayerPlugin v0.6.0 with Proguard enabled.
In release builds, the location layer isn't requesting location updates: no GPS usage icon when in foreground, and the location becomes stale a few seconds after the first launch and never updates. I'm building the plugin without providing a LocationEngine, using public LocationLayerPlugin(MapView mapView, MapboxMap mapboxMap).
It doesn't happen in debug builds (no Proguard) or if I explicitly disable Proguard in the release build (minifyEnabled=false). The proguard-rules.pro file doesn't have any specific rules for Mapbox (both SDK and plugin), I've tried adding the ones from https://github.com/mapbox/mapbox-plugins-android/blob/master/app/proguard-rules.pro but the issue remains.
Are there other rules to be added? I couldn't find anything in the documentation.

If you are using google play location services, and the GoogleLocationEngine, you can try adding
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
to your proguard-rules.pro file.
I was able to reproduce the issue and above setup helped.
However, if you are only using the AndroidLocationEngine there has been some issues with that engine recently, you can follow the issue tracker for more info.
For more context, if you will not manually add the google play location services dependency to your project, the LocationEngineProvider#obtainBestLocationEngineAvailable used by the default constructor will return the AndroidLocationEngine, otherwise, it will return the GoogleLocationEngine.

Related

Amplify.Auth.fetchAuthSession() userPoolTokens is null when shrinking the apk

I am using the amplify libraries for flutter to connect to my aws backend. After a successful call to Amplify.Auth.signIn() I use Amplify.Auth.fetchAuthSession() to access the current credentials. Like that:
final result = await Amplify.Auth.fetchAuthSession(
options: CognitoSessionOptions(getAWSCredentials: true),
);
if (!result.isSignedIn) return const None();
if (result is CognitoAuthSession) {
return Some(result.userPoolTokens.idToken);
}
But when I build an apk with flutter using the following command my code breaks.
flutter build apk
Because result.userPoolTokens is suddenly null and I get a NoSuchMethodError. The getter 'idToken' was called on null. But if I disable shrinking and build the apk with the following command everything works again.
flutter build apk --no-shrink
So I think it has something to do with the shrinking and I would prefer to shrink my app because the shrinked apk is significantly smaller.
Would appreciate any help.
This is likely due to inadequate rules being applied for the R8 shrinker.
The Amplify Android library did not vend any consumer-rules.pro until version 1.6.10 (see release notes), which was just released January 22nd, 2021.
The latest version of Amplify Flutter is 0.0.2-dev.1, and it consumes version 1.6.8 of the Android library. I've raised an issue on their GitHub repository, to update to 1.6.10.
In the meantime, you could try to apply these rules in your top-level application project.
-keep class com.amazon.** { *; }
-keep class com.amazonaws.** { *; }
-keep class com.amplifyframework.** { *; }

Signed APK network issue - Unsigned apk able to read API but signed apk keeps loading

I am using retrofit for my application. it is able to read all API data in development mode and even with Build APK. but same version of code not working in signed APK. it just move to onFailRequest. Connectivity check flag shows true that network is connected. I am unsure that it's Android 9 or higher problem. My API server have http://domainname.com only. it doesn't have https. can it be problem?
It was solved by set minify as false. (Build/Edit Buildtype) I read that "if you set this option when code release, some part is removed" so tried with false and it worked.
one other comment was there which tells add -keep class Responseclass { *; } rule in proguard rules fixed it for me.
but in mycase minify false worked.

Finotes not reporting issues

I am using Automated bug reporting SDK finotes in android.
I had integrated the sdk and it was reporting issues during development
but I created a release build for testing. Looks like it is not reporting issues anymore.
Any help will be appreciated.
As per their documentation make sure that you add the following in your pro-guard configuration
-keep class com.finotes.android.finotescore.* { *; }
-keepclassmembers class * {
#com.finotes.android.finotescore.annotation.Observe *;
}
Also make sure that, in init() function doesn’t have their dry run turned ON
dryRun flag will prevent the issues from syncing to their dashboard.
For release build, change init() in Application class to,
Fn.init(this);

Google maps android api won't work in release mode even though I specified package name and key's SHA-1 fingerprint in console

I know this sounds like a repeated question, but I am searching for two days now and I am getting nowhere.
I am using Google maps android api v2 and it is working fine in debug mode. But when I sign it with a release key, the map won't load at all.
What I have done is that:
1 - I created a new project in the google developer console
2 - I Enabled google maps api
3 - I created a new api key using the "Credentials" menu
4 - I restricted it with the my SIGNING KEY's SHA-1 fingerprint and package name (and yes, I am pretty sure that they are correct)
5 - I added the key it gave me to my manifest file :
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="blablabla"/>
But it is still only working in debug mode (I added the debug SHA-1 fingerprint exactly the way I did it with the release key), and not with my release apks
I tried everything :
regenerating the key
as some suggested, the manifest file can bee in src/debug and I should put the key in src/release. But since I am using the newest version of android studio, there are no release or debug folders in src
I tried creating a whole new project in google's developer console and it didn't work
I seriously don't know what else to do.
does anyone please have a suggestion?
ps: I am not getting any errors regarding the key being incorrect or something; The map won't just load. Even the little google logo won't appear at the bottom of the map
Ok so for all people who like me, spent days trying to figure this same issue, I finally found out what the problem was.
As opposed to what I searched for the past three days, it actually CAN be a proguard problem. Almost all the suggestions throughout the internet (and google's own api documentation) were telling me that google's apis dont't need any special proguard rules when you obfuscate your release apk. But as it turns out (or at least in my case), it dose
here's the proguard rule I added to solve the problem (a subset of these rules niether the time nor motivation to test it after three days) :
#this alone won't slove the problem. but it is good to be here
-keep class com.google.android.gms.maps.** { *; }
-keep interface com.google.android.gms.maps.** { *; }
# I saw in their code that the api uses parcelables
-keepclassmembers class * implements android.os.Parcelable {
static *** CREATOR;
}
# I added this because of a suggestion I found on the internet
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
#to be safe, don't dare touch the google apis at all
-keep class com.google.** {
public protected private *;
}
#roostaamir its not work for me. finally i found solution please follow below link might be helpful Google play app signing for this

Removing uses of TestFlight SDK with ProGuard

How can I automatically remove all uses of TestFlight SDK from my app? For example, all passCheckpoint calls:
TestFlight.passCheckpoint("FreemiumDialog opened");
My (ProGuard-obfuscated) release builds should not even attempt to send any info to TestFlight, yet I do not want to manually toggle between having TestFlight jar & its uses in my codebase.
This ProGuard configuration removes all calls to TestFlight SDK:
# Remove all TestFlight SDK calls, e.g. TestFlight.takeOff( ... );
# and TestFlight.passCheckpoint( ... );
-assumenosideeffects class com.testflightapp.lib.TestFlight { *; }
-dontwarn org.msgpack.**
Note: without the last line, ProGuard fails with a bunch of warnings like:
Warning: org.msgpack.template.builder.BeansBuildContext: can't find
referenced class javassist.CtClass
Warning: org.msgpack.util.json.JSONUnpacker: can't find referenced class > org.json.simple.parser.JSONParser
This is because the TestFlightLib jar (at least version 1.3) contains and uses a library called MessagePack. We need to either -keep it or mute the warnings. Above I'm muting warnings, since the whole point here is not to use TestFlight in release builds.

Categories

Resources