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.
Related
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 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.
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.
Uploading mapping file with command:
./gradlew -PFirebaseServiceAccountFilePath=<path> \
:app:firebaseUploadFreeReleaseProguardMapping
Runs successfully but i cannot see any tasks starting withfirebaseUpload in my app:tasks. Do somebody know why?
We also have encountered this problem.
Solution is to add minifyEnabled in your apps build.gradle like so:
buildTypes {
release {
...
minifyEnabled true
...
}
}
And sync your project, then you will have those tasks created.
#MatBos thanks for the hint. This didn't solve the problem for me.
But I had this cause:
buildTypes {
debug {
minifyEnabled true
useProguard false
}
}
When I change minifyEnabled to false it is working again!
Disabling proguard in debug mode, disabled also the firebase tasks for the production code...
You can upload mapping files manually too.
Go to destination.
app/build/outputs/mapping/debug/mapping.txt
And then upload it.
I would like to know how to run ProGuard from the command line.
I've built a hybrid app using Cordova with the Ionic Framework. One of the recommendations made to me was using ProGuard to obfuscate the java code and to remove the Log calls.
I'm not currently using Android Studio or Eclipse, I just have the project build out in Ionic Framework and Angular 1.X with the Cordova plugins I need for functionality on devices. I have Jenkins build my releases via command line.
I tried to follow the steps laid out here:
https://developer.android.com/studio/build/shrink-code.html#keep-code
and here:
Disable LogCat Output COMPLETELY in release Android app?
As well as combing through various questions/answers to find applicable bits.
My build.gradle is kept in ./vendor directory and copied to overwrite the autogenerated/default build.gradle from Ionic.
It has this for enabling ProGuard:
buildTypes {
debug {
debuggable true
minifyEnabled false
}
release {
signingConfig signingConfigs.release
debuggable false
minifyEnabled true
runProguard true
proguardFile 'customProGuard.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-android.txt'
}
}
I've also tried various versions of this line in my project.properties file:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt or proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt
It doesn't appear to be doing anything. I thought my apk file size changed at one point, but when I look at the classes in JD-GUI I can still clearly discern things. So I don't think it's running. Any help would be appreciated.
Jenkins runs the following commands:
cp -R vendor/build.gradle platforms/android/build.gradle
ionic resources
ionic prepare android
ionic build android --release
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $KEYSTORE platforms/android/build/outputs/apk/android-release-unsigned.apk
-keypass $KEY_PASSWORD -storepass $KEYSTORE_PASSWORD $ALIAS && \ ./zipalign -v 4 platforms/android/build/outputs/apk/android-release-unsigned.apk "build/appNameHere.apk"
While 'ionic build android --release' eventually calls ./platforms/android/cordova/lib/builders/GradleBuilder.js which has several lines referencing build.gradle, but I think the main most vital one being var buildGradle = fs.readFileSync(path.join(this.root, 'build.gradle'), 'utf8'); in which it reads in the file to use with GradleBuilder.build:
GradleBuilder.prototype.build = function(opts) {
var wrapper = path.join(this.root, 'gradlew');
var args = this.getArgs(opts.buildType == 'debug' ? 'debug' : 'release', opts);
return Q().then(function() {
return spawn(wrapper, args, {stdio: 'inherit'});
});
};
After much trial and error, the answer turned out to be that I needed this block of code to be located in a different segment of my build.gradle file.
release {
signingConfig signingConfigs.release
debuggable false
minifyEnabled true
proguardFile 'customProGuard.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-android.txt'
}
As it was, it was never being reached. By putting it in the android { } block, but not in any other functions or if statements, it consistently runs and behaves as expected.
Unfortunately, due to the way Ionic uses reflection, I'm not able to get much obfuscation use out of it (Apache Jira Bug). ProGuard can still be used to remove the console logs as per the linked article above though.