I am facing a strange issue that Google maps location service(Place API) is not working when I build application in release mode while it works perfectly in debug builds.
I am guessing that applying proguard rules may have created this issue tried changing proguard rules but still the issue.
My build file is like:
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
ext.alwaysUpdateBuildId = false
}
}
My proguard rules are: Proguard Rule
I have checked the log and found that LatLong are coming fine in release build too but after that Maps API are not responding (could not found any thrown exception) but something like
I/GeoApiContext: Request: {0}
AsyncTask for getting place detail using LatLong: REtrieveAddressAsyncTask
[EDIT]
I confirmed that API_KEY is not thee issue here because when I built my release APK removing Proguard rule and disabling MinifyEnabled, Geolocation api started working, so I guess something I am doing wrong in my Proguard rules and couldn't find that.
Related
At some point of devlopment I changed minifyEnabled to true without any rules in proguard then release the app to google play with v.1.4.0.
many of bugs occured to uses when updated the app, I knew the problem because the obfuscated of classes.
and some of users removed the app and reinstall to work well partially.
WebView, Camera, Gson, File Picker all this features have problems on version 1.4.0
It was my first experience with minifyEnabled, now I'm knowing that there are alot of rules should I write in the proguard to keep classes.
My question about make undo of minifyEnabled and set it to false, when I debug it, also a new problem occurs and one of them from the code below with NullPointerException.
abstract class LiveCoroutinesViewModel : ViewModel() {
inline fun <T> launchOnViewModelScope(crossinline block: suspend () -> LiveData<T>): LiveData<T> {
return liveData(viewModelScope.coroutineContext + Dispatchers.IO) {
emitSource(block())
}
}
}
note: I don't need to keep minifyEnabled = true, becuase I have alittle bit experinces and I think there are alot of keeping rules should I understand before I write them and I don't have the time now for that.
So, what is the optimal soultion (strategy) to do minifyEnabled = false for users which already working on minifyEnabled = true
The answer is not possible in my way. Because you don't have an option to handle your released app code.
My Suggestion:
Do you think that you have to write rules for Proguard? But not, Android proguard is R8 Guard not proguard. Proguard is another company guard(DexGuard). You can use the R8 guard without adding any rules because these rules are already included in all libraries(read library github and check R8 is included or not). If you enabled R8 guard then just add this line #Keep in your Model class to prevent R8 Guard to shrink that file. Add #Keep which file you don't want to minify.
Like this
#Keep // use to prevent R8 to minify this class.
public class ModelClass {
String id;
String text;
String image;
public String getImage() {
return image;
}
In new version of android, You can test your app by enabling R8 guard in debug mode by adding these below lines in your build.gradle(:app); // in module level
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug { // add this line after release and make ninify true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
It may take some time to build but it is a very good method to test if the app is caching or not (in app build time).
PS
minifyEnabled true helps to reduce app size. Very helpful if you enabled it.
It helps you in the future.
I have a flutter app that uses some Android-specific code (Java/Kotlin). In "app/build.gradle" i do have firebaseCrashlytics/mappingFileUploadEnabled true:
release {
signingConfig signingConfigs.googleplaySigningConfig
minifyEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
firebaseCrashlytics {
mappingFileUploadEnabled true
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir "build/app/intermediates/merged_native_libs/release/out/lib"
}
ndk {
debugSymbolLevel 'FULL'
}
}
Also note in root "build.gradle":
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
I build the app using flutter build appbundle and i believe it should trigger uploading of obfuscation maps to Firebase crashlytics.
However i get smth like:
which makes me think Firebase Crashlytics was unable to find deobfuscated code for obfuscated using the uploaded mapping.
What can i do or check?
PS. After reading the error message more carefully i realized it's actually Dart code where the error happens (not my Java code). However, i'm still confused why i can't see Dart stacktrace instead.
I am trying to run my android application on other devices, it installed properly but some XML file not working properly. It works as I expected when I installed through USB debugging. I am trying to find solution for many days. I don't get anything related to my issue.
This must be the result of Obfuscation
Add this lines in your build.gradle
buildTypes {
release {
...
debuggable false
shrinkResources false
minifyEnabled false
...
}
}
or you can add your files in pro-gaurd
Debug builds work fine for me. When I choose Active Build Variant = release, and try to run Build -> Generate Bundle(s) / APK(s) -> Build APK, the build runs for a while, then I get the following error:
Unexpected attempt to get register for a value without a register in method java.util.List com.chrynan.chords.parser.AsciiChordParser.parseLineAsString(java.lang.String, int, java.util.Set).
That is referencing an external library I'm pulling in. Source code for that function is available here.
What does that error mean? My searches returned nothing remotely like it.
I solved it! I have no idea why, but I set minifyEnabled = true in my build.gradle (:app):
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
This gave me instant crashing on app start due to this problem, although I think that's unrelated. I fixed that, and now my build works.
I still have no idea why that error came up though.
For some one else having the same problem, I solved it by changing
getDefaultProguardFile( 'proguard-android-optimize.txt') to
getDefaultProguardFile( 'proguard-android.txt') in build.gradle
I recently find my Android Release version can be attached through Android Studio and all logs are available to be seen as well, even though I'm sure that AndroidManifest.xml file doesn't contain "android:debuggable=true" and app's build.gradle file specified that
buildTypes {
...
release {
...
debuggable false
...
}
...
}
Do you guys have any good idea to avoid this?
You can only keep like this code below:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
hopefully works it.
Logs are nothing to do with debuggable true.
The option debuggale is to making your application debuggable in release mode, so you can attach debugger even on your release build by default it is false.
If you are using Log class and printing any log it will always display until and unless you put the check before logging them.
What you can do is put a check before every log is Build.Debug == true then print the log.
Or you can use open source library for this work like this one which provide the control of logging based on your configuration.
Or you can find a more helpful answer here.