My application was composed of only one application module. I recently tried to split it into 2 modules (a feature base and a application apk one) in order to add later an instant-app module.
My newly created feature module's AndroidManifest and gradle.build contain everything that was inside the previous application module ones:
feature AndroidManifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest package="base.package"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- all uses-permissions and permissions -->
<application>
<!-- activities, intent-filters... -->
<provider android:authorities="com.facebook.app.FacebookContentProvider663###########"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
<!-- etc -->
</application>
</manifest>
application AndroidManifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest package="app.package"
xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
feature build.gradle :
apply plugin: 'com.android.feature'
android {
buildTypes {
debug {
// debug values
}
release {
// release values
}
}
lintOptions {
checkReleaseBuilds false
}
compileSdkVersion rootProject.compileSdk
defaultConfig {
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
versionCode rootProject.versionCode
versionName rootProject.versionName
}
baseFeature true
}
dependencies {
api "com.android.support:appcompat-v7:$rootProject.supportLib"
application project(':apk')
compile "com.google.firebase:firebase-core:$rootProject.gmsLib"
compile 'com.facebook.android:facebook-android-sdk:4.27.0'
// other dependencies
}
application build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.compileSdk
defaultConfig {
applicationId "app.package"
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
versionCode rootProject.versionCode
versionName rootProject.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(":feature")
}
apply plugin: 'com.google.gms.google-services'
However, although everything builds fine, I have a problem with my APK run configuration:
When I select Default Activity in Launch Options, I get a Default Activity not found warning , and when I select a specific one, I get a The Activity 'XXXX' is not declared in AndroidManifest.xml one.
After some research, I realized this is because of an error with the apk Manifest, that I was able to find by looking at the "Merged Manifest" option. Here is the output:
I couldn't find relevant information to help me about this issue... thanks for any help!
I was able to solve this issue by adding tools:node="replace" in the <application> node of the feature's AndroidManifest. Also, don't forget to add xmlns:tools="http://schemas.android.com/tools" at Manifest top-level.
Try to add these providers in your base module and feature module to fix merge manifest error.
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="{$applicationId}.firebaseinitprovider"
android:exported="(check library provider have exported value true or false)"
tools:node="replace"/>
<provider
android:name="com.facebook.internal.FacebookInitProvider"
android:authorities="{$applicationId}.FacebookInitProvider"
android:exported="(check library provider have exported value true or false)"
tools:node="replace"/>
Related
I'm currently trying to build a hello world app as my first android auto app. Earlier, when I was trying to run the app it was giving me some minSdk error and I managed to fix that. Now, when I try to run it, it gives me this error:
Manifest merger failed : Attribute meta-data#androidx.car.app.CarAppMetadataHolderService.CAR_HARDWARE_MANAGER#value value=(androidx.car.app.hardware.ProjectedCarHardwareManager) from [androidx.car.app:app-projected:1.1.0] AndroidManifest.xml:34:17-86
is also present at [androidx.car.app:app-automotive:1.1.0] AndroidManifest.xml:44:17-87 value=(androidx.car.app.hardware.AutomotiveCarHardwareManager).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml to override.
I've been trying to follow the instructions here on how to edit the manifest file and everything looks fine according to the instructions.
Here's the AndroidManifest.xml:
<?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.smartherd.helloworld">
<uses-feature
android:name="android.hardware.type.automotive"
android:required="true" />
<application
android:allowBackup="true"
android:appCategory="audio"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.HelloWorld">
<service
android:name=".HelloWorldService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService"/>
<category android:name="androidx.car.app.category.POI"/>
</intent-filter>
</service>
<meta-data
android:name="androidx.car.app.minCarApiLevel"
android:value="1"/>
</application>
</manifest>
Build.gradle:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.smartherd.helloworld"
minSdk 29
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation("androidx.car.app:app:1.1.0")
// For Android Auto specific functionality
implementation("androidx.car.app:app-projected:1.1.0")
// For Android Automotive specific functionality
implementation("androidx.car.app:app-automotive:1.1.0")
// For testing
testImplementation("androidx.car.app:app-testing:1.2.0-rc01")
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Since you are targeting Android Automotive in your manifest, you can get rid of the following dependency in your gradle file:
implementation("androidx.car.app:app-projected:1.1.0")
That should fix the conflict you are having.
i started with following github projects but these example are not working properly. I added missing parts as stated in the docs.
https://github.com/android/app-bundle-samples/tree/main/InstantApps/urlless
https://github.com/googlecodelabs/android-dynamic-features
Here is the docs i read.
https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle
https://developer.android.com/topic/google-play-instant/feature-module-migration
https://developer.android.com/guide/app-bundle/instant-delivery
i try to implement a simple hello world instant app. I tried many things but try now button never appears in play store.
my app contains 2 module:
app
instant-app
build.gradle of app module :
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 61
versionName "61"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dynamicFeatures = [':instantapp']
}
dependencies {
...
implementation "com.google.android.gms:play-services-instantapps:17.0.0"
implementation "com.google.android.play:core:1.9.0"
...
}
build.gradle of my instant-app module
plugins {
id 'com.android.dynamic-feature'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.test.myapp"
minSdkVersion 21
targetSdkVersion 30
versionCode 3
versionName "1.2"
}
}
dependencies {
implementation "com.google.android.play:core:1.9.0"
}
AndroidManifest.xml of my app module
<?xml version="1.0" encoding="utf-8"?>
<manifest >
<dist:module dist:instant="true" />
...
</manifest>
AndroidManifest.xml of my instant-app module
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.test.instantapp"
android:targetSandboxVersion="2">
<dist:module dist:instant="true" dist:onDemand="false"
dist:title="Instant app title">
<dist:fusing dist:include="true" />
</dist:module>
<application android:usesCleartextTraffic="false">
<activity android:name=".InstantMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I generate a signed bundle and upload it in internal test in each of my try but it did not work. i tried it in prod environment too. Not work!
I tried to put applicationId "com.test.myapp" in both app module and instant-app module. I tried to made android:targetSandboxVersion="2" and android:targetSandboxVersion="1". Not work
.
Version code of my app is greater than version code of my instant-app as shown below.
I removed clearTextTraffic and added. Not work!
Some said me to take my instant app enabled code to take into production and upload a new upgraded instant app version. I did it, it did not work either.
I tried many many combinations which i cannot remember now. But try now button never appears. What is the missing part i cannot find ?
There are 3 different sayings for maximum size of instant-app module:
4 mb
10 mb
15 mb
Why the source codes and docs are conflicting too much and there is no working code in github ? If i didn't see working samples in play store, i would think instant apps are dead.
open play store -> select app-> open advanced settings -> add release type instant app
Then upload your instant app from instant apps only option:
I've downloaded support-v4-24.1.1.jar and am trying to use FileProvider, however, android:name inside of the manifest is not detecting it. This is all within an Android Module so I can use it inside of Unity.
I looked inside the jar and Android >> Support >> V4 >> Content >> FileProvider.class exists. So I don't know why I'm getting an unresolved class error.
Any help would be greatly appreciated
Android Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fileproviderplugin">
<application>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="gov.navair.aurora.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/filepaths" />
</provider>
</application>
Build.Gradle (module level)
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/support-v4-24.1.1.jar')
}
}
That library is a few years old and probably should no longer be used. And implementation is the wrong directive to use for code that you are exporting from a module.
Try this instead:
api "com.android.support:support-compat:28.0.0"
I am using the latest Android Studio 1.2.2. While trying to set AppTheme to Theme.Material according to this answer to support for older versions too(other than API 21) and many other solutions on the internet I did everything that was written. I made a different values folder named values-v21 and styles.xml in that folder. Then I wrote <uses-sdk tools:node="replace" /> , the build gave me an error saying:
Error:(6, 5) uses-sdk element cannot have a "tools:node" attribute
Error:(6, 5) Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk element cannot have a "tools:node" attribute.
Here is my app.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.amangrover.finalapp"
minSdkVersion 14
targetSdkVersion 22
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.android.support:appcompat-v7:22.2.0'
}
I thought this problem was fixed for newer versions of Android Studio?
Add this lines in your project's AndroidManifest.xml file to uses-sdk tag like this:-
<uses-sdk
tools:node="merge"
android:minSdkVersion="14"
android:targetSdkVersion="19"/>
And also add the tools name space in manifest :-
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" .....
.../>
I'm using Android Studio to build my application. I would like to use gradle buildTypes. I add a suffix to the package name with applicationIdSuffix to modify the package name for a test build type.
buildTypes {
debug {
runProguard false
proguardFile 'proguard-rules.txt'
applicationIdSuffix '.dev'
versionNameSuffix '-dev'
}
}
Is it possible to use this information in a xml file. My plan is to modify the account type:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType=<<PACKAGE NAME HERE ??>>
android:icon="#drawable/icon"
android:label="#string/app_name"/>
Thanks!
Here's another temporary workaround until the Android Gradle plugin gets support for placeholders in resource files.
You can dynamically create a String resource via Gradle in the defaultConfig and/or buildTypes and/or productFlavors closure:
android {
defaultConfig {
applicationId 'com.foo.bar'
resValue 'string', 'package_name', applicationId
}
}
You can then reference it in your authenticator.xml file just like you do for the label:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="#string/package_name"
android:icon="#drawable/icon"
android:label="#string/app_name"/>
While uou can use ${packageName} to fill in the generated package name in the Manifest:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="${packageName}"
android:icon="#drawable/icon"
android:label="#string/app_name"/>
This currently (Android Gradle 0.11) doesn't work with resource files. :-(
Instead, you must create a separate version of the resource file for each build type / variant you want with a different account type:
src
debug/res/xml/authenticator.xml (with debug package name)
main/res/xml/authenticator.xml (with default package name)
On top of jenzz's answer, i had to do this, since my case is just like as question, i add applicationIdSuffix for debug version of app.
android {
...
defaultConfig {
applicationId "..."
...
}
....
buildTypes {
release {
...
resValue 'string', 'application_id', android.defaultConfig.applicationId
}
debug {
...
applicationIdSuffix '.debug'
resValue 'string', 'application_id', android.defaultConfig.applicationId + applicationIdSuffix
}
}
Then in any xml resource, i can get application Id as like this: #string/application_id
I'm using ${applicationId} like follow for example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abnerescocio.embaixadordorei.presentation">
...
<application
...
>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.android.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths"/>
</provider>
...
</application>
</manifest>
I've just created a gradle plugin for this: com.inutilfutil.android-resource-placeholder
Just include it and placeholders will be replaced on all XML resources