React Native: Generate Signed APK: Errors while building APK - android

I have just completed my 1st react native project and now I am trying to generate its APK file by generating a signed APK using Android Studio but I am getting an error and I don't know why I am getting this.
The Gradle build starts running and after that in event log I get an error:
Generate Signed APK: Errors while building APK. You can find the errors in the 'Messages' view.
In the message view the error that I get is:
Type io.invertase.firebase.BuildConfig is defined multiple times: F:\Salvador\node_modules#react-native-firebase\app\android\build.transforms\201acb16e5bf3be0b3bc4a9933889ad1\classes\classes.dex, F:\Salvador\node_modules\react-native-firebase\android\build.transforms\9affd011dae86c883f20504c5a21ffef\classes\classes.dex

This is a problem I have been solving in my projects last days. And I think I have some good (not perfect) solution so far.
Implementation in android/app/build.gradle
def enableSeparateBuildPerCPUArchitecture = false

Related

CI/CD BitRise React Native Android Build Failing

Facing issue while build on BitRise.io
I have a React Native Project which builds successfully on local.
Using BitRise.io for CI CD.
Added App and provided all the essential information and keystore file as well.
Followed their getting started guide and everything they'll need is in place.
Tried to build multiple times but getting this error :
Failed to open project, error: no build.gradle or build.gradle.kts file found in (/Users/vagrant/git)
| x | android-build#0 (exit code: 1)
Not sure why they are not able to find build.gradle.
There was an issue with BitRise App Setup & Configuration while adding React Native App.
Although I provided Android Project Path, Module & Variant, It only added in their variables and did not add it to inputs of Build Step, I had to manually add this inside BitRise.Yml to make it work.
- android-build#0.10.0:
inputs:
- project_location: "$PROJECT_LOCATION"
- module: "$MODULE"
- variant: "$VARIANT"

React-native release apk refuses to install

I have encounter a problem I am unable to solve, I have followed all steps from:
Unable to install signed apk from React Native but the ones in Android Studio since I am not using it and the steps needed to sign the apk from https://facebook.github.io/react-native/docs/signed-apk-android, I still get the error:
There was a problem parsing the package
In logcat I get the error:
05-23 09:44:23.964 3613 3613 W PackageInstaller: Parse error when parsing manifest. Discontinuing installation
This error make me thing the error cannot be with signature but there is no manifest file, I searched for it and debug build works.
It only happens with release builds. I hope some of you can help me since I am lost.
I have recreated the project and repeated the steps, that solved the problem.

Getting Lint infrastructure error when lint baseline file is configured in android build

I am getting the following exception when I enable lint with baseline file configuration.
> Lint infrastructure error
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.........................
.........................
Caused by: java.lang.IllegalStateException: path must not be null
at com.android.tools.lint.XmlReporter.writeIssue(XmlReporter.kt:209)
at com.android.tools.lint.XmlReporter.writeIssues(XmlReporter.kt:113)
at com.android.tools.lint.XmlReporter.write(XmlReporter.kt:99)
at com.android.tools.lint.LintCliClient.run(LintCliClient.java:288)
I added following lintOptions in my module build.gradle
After which I ran lintDebug gradle task.
android{
lintOptions {
baseline file("lint-baseline.xml")
warningsAsErrors true
abortOnError true
}
}
I was expecting my changes to create lint-baseline.xml file in module root directory for the first run and fail the build indicating creation of lint-baseline.xml. For the second run the lint should read lint-baseline.xml and suppress the existing error/warning reporting.
But the first run creates empty lint-baseline.xml and fails with Lint infrastructure error. The subsequent runs did not produce Lint infrastructure error but because the file is empty, the comparison fails resulting in errors/warnings.
My app has both java and kotlin files.
This might not be the best answer, but I tried, adding an old output.json into the APK destination folder and tried to build a signed apk, then the error was known, in which we have to delete the output.json file. This time after building the APK, it worked.
Again on the other day, the above method failed, I tried deleting the release folder and creating the APK again. This time it worked.
i had this same issue, deleting the 'build' and 'release' folders. Somehow that worked for me. Don't know what actually caused it.
If the lint process successfully finished, you would get a appropriate result lint file. The error you get, shows the lint process has been failed in the first lint process run. After first run, the tools only read the empty file to determine the baseline. According to the reference you need manually delete the file and run lint process again to recreate it.
for more information you can use "Analyze > Inspect Code" in menu on the Android Studio IDE or use command line with command :
$ ./gradlew lintDebug
in both manner you can find the location of the lint-baseline.xml as output
...
Wrote XML report to file:///app/lint-baseline.xml
Created baseline file /app/lint-baseline.xml
pay attention if you use command line in the terminal of Android Studio, you must use Ctrl + Enter for running the command.
The output shows you a lot of useful information for debugging the problems.
I also faced the same issue and tried all solutions. Later, I realized there was an issue in a CSV plugin for Android Studio I installed. Since I disabled the plugin and restart the android studio, everything is working fine.

Signing The App Bundle Base Module And Dynamic Feature Module

In the Google official guide for App Bundle: https://developer.android.com/guide/app-bundle/configure#base_build_config it said that signing information only needs to be specified in the base module build.config file. The dynamic module signing info goes with base module.
I am using my own keystore file, so I only include the signingConfig in the base module. However, when I build and run the app on a device, it always pop up the error:
Installation failed with message Failed to finalize session :
INSTALL_FAILED_INVALID_APK:
/data/app/vmdl538875391.tmp/1_feature_-debug signatures are
inconsistent. It is possible that this issue is resolved by
uninstalling an existing version of the apk if it is present, and then
re-installing.
When I include the signing info in the dynamic module, the error goes away.
So does this conflict with the official guide? Or did I do anything incorrect here?
The problem is caused by a setting in Edit Configuration.. In order to only include signing info in the base module of a bundle, I need to choose 'APK from app bundle', not the 'default APK'. Otherwise, Android Studio will use the signing info to sign the APK instead of the bundle.
Do it like this
menu "Build"
run "Rebuild Project".
Then run app on device or emulator
or if the above solution doesn't work.
Then try this
Disable the Instant run in Android Studio and then Clean, Rebuild and Run, It should fix this issue.

Error:Execution failed for task ':app:proguardRelease'. java.io.IOException: Please correct the above warnings first

I am new to Android Studio. I am trying to generate release signed apk file using android-studio.
While generating signed release APK it gives me error like below.
In this module I have four library files only, they are noted in dependencies list in
build.gradle file.
Please clarify which dependencies or build types are I've missed out in this process.
I found some solutions from other users, they said please remove all library files and again add
it , then it resolves the problem. I tried in that way also but it won't works for me.
But when I tried to build release signed apk file, it gives me below warnings with error.
I have a problem with proguard. I get this on the console page.
I added -dontworn line to proguard-project.txt
Please clarify my doubt

Categories

Resources