INSTALL_FAILED_ALREADY_EXISTS with two different package names - android

I have two manifests that I swap round when building different releases of my app. The manifests have different package names yet I can only build one on the device at a time. I really need both to be built. The project has no src files and uses an activity from a library.
Manifest one:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.pkgone" android:versionCode="01" android:versionName="0.1">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name="com.test.Splashscreen" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Manifest Two:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.pkgtwo" android:versionCode="01" android:versionName="0.1">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name="com.test.Splashscreen" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

I've sorted it out! The issue was that the R.java file in the gen folder wasn't being cleaned so I just ran
ant clean
before
ant release
and it works great! Thanks to #enrmarc and #Roman Nurik for their help :)

I solved it. I had the same problem.
You need to change the "applicationId" in your build.gradle(Module:app) file
be aware that there will be two build.gradle files. Open the one with (Module:app)
then clean your project.

Related

Android app icon shorcut not launching activity

I'm trying to implement app icon shortcut on Android. I followed the documentation but I'm having problem launching the app from the shortcut. Every time I click the app icon shortcut, nothing happens.
Here's the code on my AndroidManifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.package.myapp">
<application
android:name=".MyApp"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme.NoActionBar"
android:usesCleartextTraffic="${usesCleartextTraffic}"
tools:ignore="ExportedService,GoogleAppIndexingWarning,UnusedAttribute">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="#xml/shortcuts" />
</activity>
...
</application>
</manifest>
Here's the shortcuts.xml file:
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<shortcut
android:enabled="true"
android:icon="#drawable/ic_send"
android:shortcutId="send_funds"
android:shortcutLongLabel="#string/LBL_SEND_FUNDS"
android:shortcutShortLabel="#string/BTN_SEND">
<intent
android:action="android.intent.action.VIEW"
android:targetClass="com.package.myapp.MainActivity"
android:targetPackage="com.package.myapp" />
</shortcut>
</shortcuts>
So the issue was on the buildType. When running on buildTypes other than the release build, I'm having the issue because the package name is different from what was indicated on the android:targetPackage of shortcut's intent. So what I did was, I created multiple shortcuts.xml with different targetPackage in the respective build folder:
app/src/debug/res/xml/shortcuts.xml
app/src/dev/res/xml/shortcuts.xml
app/src/staging/res/xml/shortcuts.xml
And set the android:targetPackage respectively:
android:targetPackage="com.package.myapp.debug"
android:targetPackage="com.package.myapp.dev"
android:targetPackage="com.package.myapp.staging"
Thanks to this SO question which is almost similar to my issue. And to Rakesh's answer.

Elements not allowed here in android manifest file

I made a new project in Android studio, and this is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cro.perger.rajcica" >
<application
android:allowBackup="false"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".rajcica" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
When I build my file I get few gradle errors, and I get this debug/manifest file open:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cro.perger.rajcica"
android:versionCode="10"
android:versionName="2.0.1" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name="cro.perger.rajcica.rajcica" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I get this errors:
URI not registered
element not allowed for (versionCode, versionName, icon, allowBackup, theme, supportsRtl)
Don't know how to resolve this, because many of this attributes are deleted from my manifest file, but not from debug/manifest file :(
Please help
If you removed those lines from the manifest, but they are still in your debug, then it sounds like your manifest is in the wrong folder. Something changed in your directory structure maybe and you did not realize or intend for that to happen.
Get the manifest in the right folder and make sure that you are editing the correct one.
See this related post: Why is Android Studio reporting "URI is not registered"?
It also could be that you are setting them in your build.gradle file - check there.

Two manifest tags get created when I add an activity

With everything checked, when I create a new activity two manifest tags are created automatically and it shows an error. Should I uncheck something when creating a new activity before clicking finish in the preview section? My manifest code is below:
<<<<<<< Original
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iamtheonewhoknocks.toolkit"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.iamtheonewhoknocks.toolkit.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>
<activity
android:name="com.iamtheonewhoknocks.toolkit.FlashlightActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/title_activity_flashlight"
android:parentActivityName="com.iamtheonewhoknocks.toolkit.MainActivity"
android:theme="#style/FullscreenTheme" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.iamtheonewhoknocks.toolkit.MainActivity" />
</activity>
</application>
</manifest>
=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<activity android:name=".FlashlightActivity"
android:label="#string/title_activity_flashlight"
>
</activity>
</application>
</manifest>
>>>>>>> Added
Those <<<<<<< Original and other tags were created automatically. Why is it doing this?
<intent-filter>
<action android:name="android.intent.FlashLight." />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
I don't know what IDE you are using ~ I am going to assume the Eclipse IDE Android bundle. When you create a new activity in the android manifest you need an intent filter within the activity xml files. So when you call a new activity in the src java files. You should have something like the code above in yours, but the 'FlashLight' at the end of android:name can be anything you want as long as you remember it and it makes sense. This is what seems to be missing from your code.
A quick work around would be to delete everything but:
<activity
android:name="com.iamtheonewhoknocks.toolkit.FlashlightActivity"
android:label="#string/title_activity_flashlight"
</activity>
and then add in that snippet of code at the top.
<activity
android:name="com.iamtheonewhoknocks.toolkit.FlashlightActivity"
android:label="#string/title_activity_flashlight"
<intent-filter>
<action android:name="android.intent.FlashLight." />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Hope this helps

Test project icon not visible in android

I am unit testing an android applications using Robitium. When I install the test project in to android emulator, I can't find the icon of the test project, but I can run it.
The manifest file of the test project is like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.smartek.screens.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.smartek.screens" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
What should I do to make the test project icon visible?
The test project will not contain the launcher entry in manifest file, so you cannot see the icon on launcher.
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
We can do this and its same as the normal android application .
Add the following lines to the android manifest file
<activity android:name=".Testing class name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Error in Android manifest file

My manifest FILE IS:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.Smsr"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:label="#string/app_name"
android:targetPackage="com.example.Smsr" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".SmsrActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".SimpleSmsReciever" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
Error is :smsr does not specify a android.test.InstrumentationTestRunner instrumentation or does not declare uses-library android.test.runner in its AndroidManifest.xml
i have two classes here , first is main activity i.e smsrActivity and other is simplesmsreciever class , help me
thanx in advance
I think may be ur problem is you have to set minsdk version and target version. Then it will work
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="20" />
You are missing <uses-library android:name="android.test.runner" /> in application tag.
for more causes and detailed knowledge check out a previous question
Android Eclipse Plugin: Instrumentation Test Runner not specified
try to run your application as android application. right click your application folder and go down to run as --> android application.
I don't know how or why but this worked with me :)

Categories

Resources