gradle placeholder support problem :
my placeholder looks like ${com.nssb.zssb}
how can gradle deal with this situation, I tried the following command:
manifestPlaceholders = [com.nssb.zssb:"djdssb"]
but it didnt worked. any suggestion? many thanks~~~~~
my mainifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="differentbuild.com.mike.differentbuild" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="${com.nssb.zssb}"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="${com.nssb.zssb}" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SecondActivity"
android:label="${com.nssb.zssb}" >
</activity>
</application>
</manifest>
my build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "differentbuild.com.mike.differentbuild"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
production {
applicationId "differentbuild.com.mike.differentbuild"
manifestPlaceholders = [com.nssb.zssb:"SecondActivity"]
versionName "1.0-pro"
}
pros {
applicationId "differentbuild.com.mike.differentbuild"
manifestPlaceholders = [com.nssb.zssb:"SecondActivity111"]
versionName "1.0.1-pro"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}
Related
I am trying to build the signed app bundle, so publishing. All I did was update the OS versions and some graphics. The app runs on the ADKs just fine.
When building the signed apk, I get this error message:
"Version code not found in manifest."
This is the error log:
"Caused by: com.android.ide.common.workers.WorkerExecutorException:
1 exception was raised by workers:
com.android.tools.build.bundletool.exceptions.manifest.ManifestVersionException$VersionCodeMissingException:
Version code not found in manifest."
Thanks for anyone that can help me sort this small issue out. I searched on here and could not find a good fix.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sevillasoundservices.warningshot">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ShotgunSensing"
android:label="#string/title_activity_shotgun"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".RifleSensing"
android:label="#string/title_activity_rifle"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PistolSensing"
android:label="#string/title_activity_pistol"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.sevillasoundservices.warningshot"
minSdkVersion 24
targetSdkVersion 28
versionName '1.0.2'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13-beta-3'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
I am hoping someone here can tell me what is missing. I expect to simply insert some code on the manifest file to sort this out, however, all other examples of other coders manifests do not have any version showing anywhere.
Add the versionCode to your gradle. Something like below...
defaultConfig {
applicationId "com.sevillasoundservices.warningshot"
minSdkVersion 24
targetSdkVersion 28
versionName '1.0.2'
versionCode 3
}
The versionCode is an incremental integer that is used to determine which version is higher than the other. I think this is only enforced on signed APKs, that's why you haven't seen the error earlier.
More info can be found in Android Developer Guides
You need to add versionCode code as follows.
android {
compileSdkVersion 32
defaultConfig {
minSdkVersion 28
targetSdkVersion 32
versionCode 4
versionName '0.0.4.'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
For me, Error was in my build.gradle that I was trying to generate VersionCode dynamically. For that I need to add a method that generated versionCode. It had no issue till I tried to generate a release. But got the error when I tried creating signed bundle.
def getVersionCode() {
def date = new Date()
def formattedDate = date.format('yyyyMMdd')
return formattedDate
}
android {
compileSdkVersion 32
defaultConfig {
minSdkVersion 28
targetSdkVersion 32
versionCode getVersionCode()
versionName '0.0.4.'
}
The reason was my method name getVersionCode() conflicted with the default getter for field versionCode and was hiding it.
If you want dynamic generation like the above your method name has to be something other than getVersionCode(), may be generatetVersionCode()
After I imported the BaseGameUtils module (for Google Play Game Services), I got this error. The error log says to use in my Module Manifest File:
<uses-sdk tools:overrideLibrary="android.support.v7.appcompat"/>
Then, when I build this happens:
Then, the errorLog suggests me to import this into my Module's Manifest File:
<uses-sdk tools:overrideLibrary="android.support.v4"/>
Then, I get the first error again, It's a never-ending back and forth cycle.
App Manifest XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tool="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
package="reflexflash.gespanet2015.com.flashreflex">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Arcade1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
App Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
applicationId "reflexflash.gespanet2015.com.flashreflex"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':BaseGameUtils')
}
Module Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.example.games.basegameutils"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk tools:overrideLibrary="android.support.v4"/>
<application>
</application>
</manifest>
Module Gradle:
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
dependencies {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('appcompat_library_version')) {
ext.appcompat_library_version = '20.0.+'
}
if (!project.hasProperty('support_library_version')) {
ext.support_library_version = '20.0.+'
}
if (!project.hasProperty('gms_library_version')) {
ext.gms_library_version = '8.1.0'
}
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile "com.google.android.gms:play-services- games:${gms_library_version}"
compile "com.google.android.gms:play-services- plus:${gms_library_version}"
}
android {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('android_compile_version')) {
ext.android_compile_version = 23
}
if (!project.hasProperty('android_version')) {
ext.android_version = '23'
}
compileSdkVersion android_compile_version
buildToolsVersion android_version
Change your gradle (app).
android {
...
defaultConfig {
applicationId "your.package.name"
minSdkVersion 7 //here your problem. Change that 1 to 7(or value of the that you are currently using libraries)
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
multiDexEnabled true
...
}
In the Module's manifest, i added this line to fix it:
<uses-sdk android:minSdkVersion="15" />
my minSdkVersion is also stated in my app's gradle file.
I have added a new dependency to my build.grade.after adding there is a error in my manifest.XML.the error is ERROR PARSING XML: UNBOUND PREFIX
Here is my manifest.XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ravakri.wm" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:authorities="com.ravakri.wm.notesprovider"
android:name=".NotesProvider"
android:exported="false"/>
</application>
</manifest>
Here is my build.grade
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.ravakri.wm"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'it.neokree:MaterialTabs:0.11'
}
Thanks in advance
manifest tag is not closed add
</manifest>
in the last line of your manifest file
I hope to display different app name based free and pro version.
I define buildConfigField "String", "AppName", "\"Message Cleanup\"" in build.gradle, but I don't know how to apply to android:label in AndroidManifest.xml.
Could you help me ? Thanks!
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.dodata.messagecleanup" >
<application
android:allowBackup="true"
android:icon="#mipmap/clenupmessage"
android:label="AppName"
android:theme="#style/AppTheme" >
<activity android:name="ui.CleanupDelete"
android:label="AppName">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "info.dodata.messagecleanup"
minSdkVersion 9
targetSdkVersion 22
versionCode 7
versionName "1.07"
archivesBaseName = "MessageCleanup-V" + versionName
}
productFlavors {
free {
applicationId "info.dodata.messagecleanup"
buildConfigField "String", "AppName", "\"Message Cleanup\""
}
pro {
applicationId "info.dodata.messagecleanup.pro"
buildConfigField "String", "AppName", "\"Message Cleanup Pro\""
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.3.0'
}
To kcoppock
The manifestPlaceholders can do that.
productFlavors {
wandoujia {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "wandoujia"]
}
baidu {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "New"]
}
c360 {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "c360"]
}
uc {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "uc"]
}
}
In AndroidManifest.xml, I can use it as the following code
<meta-data
android:name="UMENG_CHANNEL"
android:value="${UMENG_CHANNEL_VALUE}" />
Assuming you are using the standard project structure (e.g. you have something like src/main/res/values/strings.xml), create additional directories for each flavor:
src/free/res/values/strings.xml
src/pro/res/values/strings.xml
And define the same string key (e.g. app_name) in both of those files, with the correct value for each variant. So you'd have something like:
src/free/res/values/strings.xml
<string name="app_name">Message Cleanup</string>
src/pro/res/values/strings.xml
<string name="app_name">Message Cleanup Pro</string>
The resource merger will merge in these strings based on which variant is being built. Now you can just refer to the app_name string in code, and know that it'll render correctly based on the currently built flavor.
I have an AVD emulator set at API 18 and my manifest is as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pushpindesigns.com.lines"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="12" android:targetSdkVersion="20"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".mainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Level_1"
android:label="#string/title_activity_level_1" >
</activity>
</application>
Updated build.gradle file that includes the compilesdkversion = 18
apply plugin: 'com.android.application'
android {
compileSdkVersion 18
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "pushpindesigns.com.lines"
minSdkVersion 8
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Code above is updated and still doesn't work.................Let me know what you think
Replace android-L with something else -- 20 or 19 would be likely choices. The "L" Developer Preview will not work on anything but "L"-equipped devices and emulators.
Also, the targetSdkVersion in your build.gradle overrides that which is in your manifest. Replace the targetSdkVersion in your build.gradle to 20.