I use ./gradlew assembleAndroidTest to create app-debug-androidTest.apk, but the versionCode for apk is always 0. Is there any to set the versionCode for app-debug-androidTest.apk.
Thanks!
For normal apk, I can set in AndroidManifest.xml:
android:versionCode="110"
android:versionName="3.0.17 alpha"
or in build.gralde:
defaultConfig {
applicationId "com.android.searchui"
minSdkVersion 18
targetSdkVersion 22
versionCode 84
versionName "9.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
But when during instrumented tests, there are generated two .apk files. And the smaller one is app-debug-androidTest-unaligned.apk and it's versionCode is 0.
Updated on 2017/8/4:
I think it's very difficult to do this because the com.android.application gradle plugin didn't provider androidTest apk versionCode setting.
So I just put a version.xml to src/androidTest/res/values folder:
<resources>
<integer name="versionCode">111</integer>
</resources>
Use this to fake versionCode.
Just add this to your manifest
android:versionCode="110"
android:versionName="3.0.17 alpha"
you can set your desired version code and name
Go to /app/build.gradle.
There you can give versionCode and versionName
For eg
defaultConfig {
applicationId "your package name"
minSdkVersion 17
targetSdkVersion 25
versionCode 2
versionName "1.0.1"
}
you can copy the src/main/AndroidManifest.xml to src/androidTest/AndroidManifest.xml
then add android:versionCode and android:versionName in src/androidTest/AndroidManifest.xml
dump test apk
java -jar ~/apktool_2.4.0.jar d ./app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
copy AndroidManifest.xml to androidTest
cp app-debug-androidTest/AndroidManifest.xml app/src/androidTest/
add android:versionCode and android:versionName in AndroidManifest.xml
rebuild test apk
Related
Since I upgraded Gradle it removed the versionCode and versionName properties from the gradle file on one of my app's libraries, but didn't remove them from my app's own gradle file.
Can anyone explain me why this happened? Can't I define version numbers for my library? Should I be setting my version numbers elsewhere?
Since gradle removed the versionCode & versionName for modules, I'm setting my module's (library) version code & version name like this:
defaultConfig {
minSdkVersion ...
targetSdkVersion ...
...
versionCode 1
versionName "1.0.0"
buildConfigField("int", "VERSION_CODE", "${defaultConfig.versionCode}")
buildConfigField("String","VERSION_NAME", "\"${defaultConfig.versionName}\"")
...
}
This will add the numbers to your BuildConfig.VERSION_CODE & BuildConfig.VERSION_NAME so apps that uses your library can know the library's version.
I already generated an unsigned APK file for my project last month, and, now when I want to generate a new APK file based on my existing progress, it still shows the same version. How can I build and generate a new APK file altogether?
Have you tried generating new apk by changing versionCode and versionName to updated one. My previous version code was 1 and version name was 1, I have changes it like:
defaultConfig {
applicationId "com.test.example"
minSdkVersion 19
targetSdkVersion 28
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
I have followed the official guide for creating different flavours of my Flutter application.
When I build either of the flavours on my emulator,
flutter build apk --flavor a -t lib/main-a.dart
flutter install
the app succesfully builds but instantly crashes on startup. I have looked at other solutions but none seem to work.
I checked if my package names are the same.
android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutterclient">
android/app/build.gradle
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
flavorDimensions "app"
productFlavors {
a {
dimension "app"
applicationId "com.example.flutterclient"
versionCode 1
versionName "1.0"
}
b {
dimension "app"
applicationId "com.example.flutterclient"
versionCode 1
versionName "1.0"
}
}
app/src/main/java/com/example/flutterclient/MainActivity.java
package com.example.flutterclient;
I've tried flutter clean before building
Any help is appreciated!
Android Studio 2.3.3, Gradle 4.2
My app/build.gradle snippet:
defaultConfig {
applicationId "com.myproject"
minSdkVersion 16
targetSdkVersion 23
versionCode 3
versionName "1.2.3"
}
My steps to create release distributive (apk):
Increment versionCode and versionName
Run, from console, command: gradlew assembleRelease
OK. It's work.
But I do not want manually increment versionCode/versionName before create distributive.
Is it possible to automate it? Or I need to write custom Gradle task?
I'd like to create a demo from my application, so I tried to build another flavor, but if I try to run it, I get this exception:
attempt to write a readonly database (code 1032)
Original Gradle
defaultConfig {
minSdkVersion 9
targetSdkVersion 24
applicationId 'com.myapp.foo'
versionCode 518
versionName '4.3.2'
}
and this is my gradle with the two flavors
defaultConfig {
minSdkVersion 9
targetSdkVersion 24
}
productFlavors {
baz {
applicationId 'com.myapp.baz'
versionCode 1
versionName '1.0.0'
}
foo {
applicationId 'com.myapp.foo'
versionCode 518
versionName '4.3.2'
}
}
Are you sure you have your flavor specific source segmented correctly so that you only have one SQLiteOpenHelper? Meaning you have one under src/baz/java and one under src/foo/java but not one under src/main/java? Or just a single one under src/main/java?
In your AndroidManifest.xml provider section, it should be like the below one.
<provider
android:name="com.zoho.invoice.provider.ZInvoiceProvider"
android:authorities="${applicationId}"
android:writePermission="${applicationId}.permission.WRITE_SCHEDULE" />
So that the appropriate application id will be replaced while build process.
Also, in your whole project where ever, you use your application id, should be replace with the placeholder.
In your Java file, it can be accessed as
BuildConfig.APPLICATION_ID