I have a small android application with this manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.eliran.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.eliran.myapplication.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>
</application>
</manifest>
I want alter the package name for testing integration with another andorid app.
However when I change to
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myTest.driver" >
I get an error that R class is not found
Error:(37, 25) error: package R does not exist
how can i fix this, with minimal effort and without changing the package name of each class?
Step #1: Return your package attribute to its original value
Step #2: Add applicationId to defaultConfig in your module's build.gradle file to your revised application ID
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
applicationId "com.commonsware.android.espresso"
}
}
This gives your app a separate application ID (the unique identifier for installation purposes) but keeps the package name the same (for R generation, etc.).
You need to change the applicationID in your build.gradle file
Related
I updated the Android Studio to version 3.1 and the Gradle for my Project to version 3.1.0.
Since then I had some problems related to merging multiple files, but that I was able to solve.
Then I had this error:
> Manifest merger failed :
Attribute activity#com.aware.ui.PermissionsHandler#launchMode
value=(singleTop) from [com.awareframework:aware-core:4.0.555]
AndroidManifest.xml:35:13-43 is also present at
[com.github.denzilferreira:aware-client:4.0.555]
AndroidManifest.xml:44:13-42 value=(standard).
Suggestion: add 'tools:replace="android:launchMode"' to <activity>
element at AndroidManifest.xml:30:9-37:66 to override.
So, first I tried to use tools:replace="android:launchMode" inside the mentioned Activity:
<activity android:name=".MainActivity"
...
tools:replace="android:launchMode"
android:launchMode="standard">
</activity>
But it did not solve the problem, then I searched and found some similar questions and their responses.
One of them said to delete the proposed attribute from the libraries that were conflicting:
<activity
android:name="com.aware.ui.PermissionsHandler"
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleTop" //deleted this line from Manifests
android:noHistory="true"
android:theme="#style/Theme.AppCompat.Translucent" />
But again, with no success. I also tried to use tools:replace="android:launchMode" inside the application tag:
<application
...
tools:replace="android:launchMode">
An then use the android:launchMode="standard" inside the activity tag.
<activity android:name=".MainActivity"
....
android:launchMode="standard">
</activity>
But it throws a different error:
tools:replace specified at line:16 for attribute android:launchMode,
but no new value specified
I also tried to reorder the dependencies inside the Gradle files, like #GLee answered here but it did not make any difference.
This is one of the libraries I'm using that is conflicting: Aware Activity Recognition Plugin.
And this is the tutorial I used to create the application: Creating a standalone application.
Another relevant thing to say is that the two dependencies conflicting are in different modules, the com.awareframework:aware-core:4.0.555 dependency is inside the app module and the com.github.denzilferreira:aware-client:4.0.555 is inside the activity_recognition module.
Finally, this is my App Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "app.miti.com.iot_reduce_daily_stress_application"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
...
}
dependencies {
...
implementation "com.awareframework:aware-core:${aware_libs}"
implementation "com.android.support:appcompat-v7:${support_libs}"
implementation "com.android.support:cardview-v7:${support_libs}"
implementation "com.google.android.gms:play-services-location:${gms_libs}"
implementation "com.google.android.gms:play-services-maps:${gms_libs}"
implementation "com.google.android.gms:play-services-places:${gms_libs}"
implementation 'com.android.support:preference-v14:${support_libs}'
implementation "com.android.support:design:${support_libs}"
implementation 'pub.devrel:easypermissions:1.2.0'
implementation 'com.android.support:multidex:1.0.3'
implementation "com.google.firebase:firebase-core:${firebase_libs}"
implementation "com.google.firebase:firebase-messaging:${firebase_libs}"
...
}
And this is my activity_recognition module Gradle file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode version_code
versionName version_readable
multiDexEnabled true
}
...
}
dependencies {
...
implementation "com.google.android.gms:play-services-location:${google_libs}"
implementation "com.android.support:appcompat-v7:${support_libs}"
api "com.github.denzilferreira:aware-client:${aware_libs}"
implementation "com.koushikdutta.ion:ion:2.1.6"
implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2"
}
This is the App AndroidManifest.xml (error URL directs to this file):
<?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="app.miti.com.iot_reduce_daily_stress_application">
... //permissions
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
<activity android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:parentActivityName=".MainActivity"
tools:ignore="UnusedAttribute">
</activity>
</application>
</manifest>
Since this is not a dependencies version problem, like many other questions I found, and because I have to use this library dependencies in my Project, how can I solve this problem?
P.S: I have already tried the usual methods:
Invalidate Caches/Restart
Deleted Gradle
Clean Project and Rebuild Project
...
The problem is with com.aware.ui.PermissionsHandler, which is why putting attributes on .MainActivity will not help, as that is a different activity. Since you are using artifacts in your posted Gradle files, I'm not sure where you were modifying the manifests of the libraries.
In your app's manifest, add:
<activity
android:name="com.aware.ui.PermissionsHandler"
android:launchMode="..."
tools:replace="android:launchMode"
/>
where ... is your desired launchMode value, perhaps after some discussion with the developers of those libraries to determine what the right answer is.
You shouldn't need any other attributes or child elements — they should all get merged in via the manifest merger process.
I'm beginner in android and get this error when try to build project:
Manifest merger failed with multiple errors, see logs
read some answer in stack over flow but can not solve my problem,my gradle is this:
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.behineh.seaapp"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
and this is my manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.behineh.seaapp">
<application
android:allowBackup="true"
tools:replace="android:allowBackup"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:roundIcon="#mipmap/ic_launcher_round"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"></activity>
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
how can i solve problem?thanks all.
my full error log:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
Your APK file can contain just one AndroidManifest.xml file, but your Android Studio project may contain several—provided by the main source set, build variants, and imported libraries. So when building your app, the Gradle build merges all manifest files into a single manifest file
You can merge manifest like this
<application
tools:node="merge"
tools:replace="android:label, android:icon, android:theme,
android:allowBackup">
</application>
Check android developer documentation for further detail
https://developer.android.com/studio/build/manifest-merge.html
I recently tried to edit my 4 year old android application in the recently appeared Android Studio 2.3.1.
After importing the code I can launch it on my mobile phone. However the action bar seems to have disappeared. What has gone wrong?
How can I tell android to display the action bar?
I have implemented the action bar activity like this:
public class MainActivity extends ActionBarActivity
My build.gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "de.my.app"
minSdkVersion 8
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
I also tried to replace the compile command with something newer one:
compile 'com.android.support:appcompat-v7:25.3.1'
but already the syncing in android studio fails like this, throwing the following error:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library [com.android.support:appcompat-v7:25.3.1] /home/user/.android/build-cache/815cafa5312f1d889eb1134b2184a62b3f88d8a3/output/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
I haven't done much android coding in the last 4 years so I assume the ActionBar stuff has changed profoundly but shouldn't there be a way to compile the old code as it is using android studio?
Edit:
This is the manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.myApp.myAppDemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/icon_app"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="de.myApp.myAppDemo.Splash"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.MainActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#style/Theme.AppCompat.Light">
<intent-filter>
<action android:name="de.myApp.myAppDemo.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.PropertiesAssign"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="de.myApp.myAppDemo.PROPERTIESASSIGN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="de.myApp.myAppDemo.PropertiesView"
android:label="#string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="de.myApp.myAppDemo.PROPERTIESVIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Meanwhile I got at least the ActionBar to be displayed. However I had to increase the MinSDK and targetSdkVersion / compileSdkVersion bigly: From 8,17 to 15,23. Moreover I had to look in the SDK-Manager to see which exact version of Android Support Library was installed on my system (23.2.0) and adapt the corresponding line in build.gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23 //->modified
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "de.Geo.geodraw"
minSdkVersion 15 //->modified
targetSdkVersion 23 //->modified
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile "com.android.support:appcompat-v7:23.2.0" //->modified
}
Not sure whether it was relevant or necessary but following this page I also added
allprojects {
repositories {
jcenter()
maven { //->modified
url "https://maven.google.com" //->modified
} //->modified
}
}
in another build.gradle file.
If there is another solution without drastically changing minSdk and targetSdk I will accept that answer.
I've changed applicationId and after that search functionality in my application stopped working. I initiate search via:
activity.onSearchRequested();
Essential part of AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androzic" >
<application
android:name=".Androzic"
android:icon="#drawable/icon"
android:label="#string/app_name" >
<activity
android:name=".SearchableActivity"
android:exported="true"
android:label="#string/search_name"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
</application>
</manifest>
Essential part of build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.androzic.v2"
minSdkVersion 8
targetSdkVersion 21
}
}
How do I properly configure search if my applicationId is not the same as package id?
If you specified applicationId with other value than package attribute, it's safe to set full qualified class name as android:value of meta-data element, like below.
<activity
android:name="com.androzic.SearchableActivity"
.../>
or
<meta-data
android:name="android.app.default_searchable"
android:value="com.androzic.SearchableActivity" />
Write this before </application>
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchableActivity" />
Im using AndroidStudio and Im trying to put some ads on my app, according to the setting up google play API - https://developer.android.com/google/play-services/setup.html
Adter i sync the project with the grandle files i get this error:
Error:Failed to find: com.google.android.gms:play-services:5.0.77
Install Repository and sync project<br>Open File<br>Open in Project Structure dialog
This is my gradle.build:
apply plugin: 'com.android.application'
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.pachu.fartsounds"
minSdkVersion 8
targetSdkVersion 19
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.+'
compile 'com.google.android.gms:play-services:5.0.77'
}
My Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pachu.fartsounds">
<application
android:allowBackup="true"
android:icon="#drawable/fart_icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".FartActivity"
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>
</application>
Any ideas? Thanks !
You are missing critical components of your manifest. The SDK error you are receiving is because the compiler doesn't know at what SDK level to compile your app - you're missing <uses-sdk.
And while we're at it, you're also missing your package name, version name, and version code. These are all critical components to your app. Here's an example of a well-formed manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.exampleapp"
android:versionCode="2"
android:versionName="v0.2-Alpha" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.GET_TASKS" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.exampleapp.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>
<service android:enabled="true" android:name="com.example.exampleapp.MyService" />
</application>
</manifest>
Notice at the very top: the sections that read package, android:versionCode, and android:versionName. And also, below those, the entire section that starts with <uses-sdk... These are all required.
Add this to your build.gradle:
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
}
I had the same issue and fixed it next way:
in build.gradle file of module (usually in app, not in root project directory) I set
android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
// your application version and id settings
}
where 19 - is and SDK I have completely loaded in Android SDK Manager
(same values checked in Studio module settings, Properties and Flavors tabs).
So, may be your problem is a cause of minSdkVersion 8 value, when you don't have 8 API installed.
I had the same error.
In my case the package 'Extras\Google Repository' was not installed.
So after installing it in SDK Manager the problem had gone.