I'm trying to set android app version code and name using project variables on running:
./gradlew bundleRelease -PversionName=1.0.0 -PversionCode=100
To use this on my app/build.gradle file:
defaultConfig {
versionCode project.versionCode
versionName project.versionName
[...]
}
I remember to use this once, but this time I'm receiving the following weird error:
A problem occurred evaluating project ':app'.
> No signature of method: build_3d8oq36p9lc2a0ylsa4yduj2n.android() is applicable for argument types: (build_3d8oq36p9lc2a0ylsa4yduj2n$_run_closure1) values: [build_3d8oq36p9lc2a0ylsa4yduj2n$_run_closure1#6e40553b]
How can I set the app version code and name with gradle on the command line?
Thanks, #akif for the help!
defaultConfig {
versionCode project.versionCode.toInteger()
versionName project.versionName
[...]
}
Related
I´m using flutter version 3.4.0 with cloud_firestore version ^4.1.0 and I´m getting this error:
`Execution failed for task ':app:processDebugMainManifest'
Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:cloud_firestore]`
How should I change version of the minSdk from 16 to 19?
This is my defaultConfig:
`
defaultConfig {
applicationId "com.example.example"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
`
Add this line into your local_properties :
flutter.minSdkVersion=21
Then in your build.gradle under the app folder find the defaultConfig and replace value of minSdkVersion for localProperties.getProperty(‘flutter.minSdkVersion’).toInteger()
To finish just type commands flutter clean and flutter pub get
you need to modify it in your build.gradle file.
see: Flutter Execution failed for task ':app:processDebugResources'
Hope it works!
I generated a project using React-Native and followed the official RN guide to publish to Play Store.
When I get to the buildRelease step. This outputs the following error:
Execution failed for task ':java:packageReleaseBundle'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Version code not found in manifest.
When I use assembleRelease however, the build creates an apk without any issues. What am I missing?
The default config under app/build.gradle is configured as such:
defaultConfig {
applicationId "com.company.appname"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0.0"
missingDimensionStrategy 'react-native-camera', 'general'
}
In my case, i had to disable enableSeparateBuildPerCPUArchitecture
def enableSeparateBuildPerCPUArchitecture = false
I was trying to add Firebase Crashlytics to my app and I followed this tutorial. When I ran the app, I am getting the following duplication runtime exception.
Execution failed for task ':app:mergeDebugResources'.
> [string/com.crashlytics.android.build_id] /home/chinkysight/Desktop/Pecha/build/app/generated/fabric/res/debug/values/com_crashlytics_build_id.xml [string/com.crashlytics.android.build_id] /home/chinkysight/Desktop/Pecha/build/app/generated/crashlytics/res/debug/values/com_crashlytics_build_id.xml: Error: Duplicate resources
Try to delete your build folder in app/build. And then try a clean build
Might be you have not enabled multidex,
Please go to app/build.gradle, if it is not enabled then enable it and restart the app again.
here is how you can do that:
Goto ->
/android/app/build.gradle and add
multidrxEnabled true
In defaultConfig
It should look like this:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.chat_app_flutter_firebase"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//Enable multidex by adding this line
multiDexEnabled true
}
C:\Users\hp-\IdeaProjects\new\app\build.gradle
Error:(11, 0) Gradle DSL method not found: 'versionCode()'
Possible causes:<ul><li>The project 'new' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li>
<li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
This was the error how to fix it?
I will change in build.gradle as follows
defaultConfig {
applicationId " name.name"
minSdkVersion 15
targetSdkVersion 24
versionCode 1.1
versionName "1.1"
}
you cant use a float number for versionCode. you must use an integer number.
just versionCode must be more than previous versionCode like it:
1, 2, 3, 4, ...
i have a build.gradle file in my android app with this settings:
android {
...
defaultConfig {
applicationId "some.app.id"
versionName '1.2'
versionCode 3
...
}
...
}
My AndroidManifest.xml does not contain versionCode and not contain versionName.
Now i want to build this app on Jenkins and pass BUILD_NUMBER as a versionCode for app, so that every build has a higher version.
So in job I hava a call:
./gradlew -PversionCode=$BUILD_NUMBER clean build
When i use "versionCode" to rename "app-release.apk" value of versionCode is the same as passed from command line:
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace("app-release.apk", "MyApp_" + "_v" + versionName + "." + versionCode + ".apk"))
}
}
Summary
So I have a default value of "versionCode" set to 3, but when building on Jenkins I want to override it from command line.
The problem
The problem is that in AndroidManifest inside build .apk app has versionCode set to 3 instead of value from BUILD_NUMBER.
I checked it with "aapt dump badging"
The question
Can this value "versionCode" from android defaultConfig be overriden by command line parameter?
I know, I could use a function as explained in:
http://robertomurray.co.uk/blog/2013/gradle-android-inject-version-code-from-command-line-parameter/
but I prefer the cleaner way of simple override but I cant get it working.
You can use properties by defining them in a gradle.properties file, see gradle documentation.
But you'll have to be really careful which names you use for your properties: if you use versionName that property will have the correct value in gradle (you can println it) but it won't end up in your AndroidManifest.xml! So I chose to use 'versName'. (I don't know enough about gradle to understand why this is so...)
So in your project's gradle.properties you can define the following properties:
versCode=3
versName=1.2
And then change the build.gradle file into:
android {
...
defaultConfig {
applicationId "some.app.id"
versionName versName
versionCode versCode as Integer
...
}
...
}
Now you can override them on the command line like this: ./gradlew -PversCode=4 -PversName=2.1.3 clean build