Changes Needed after changing package structure of android project? - android

I am doing one android project in android studio,previously it was working totally fine in Genymotion as well as in actual Mobile phone.
But later when it was needed , I changed my package structure,I made related changes in AndroidManifest.xml and build.gradle.Still after that,it was running perfectly on Genymotion but when I tried running it on mobile phone,it is showing error
Waiting for device.
Target device: samsung-gt_b5330-4d000ef10dee7f00
Uploading file
local path: F:\AppName\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.aaa
Installing com.aaa
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.aaa"
pkg: /data/local/tmp/com.aaa
Failure [INSTALL_FAILED_OLDER_SDK]
for example let me tell you how old package was for some classes
com.aaa.bbb.ccc.ddd
so my common package for all activity was
com.aaa.bbb
mean all other packages was under this package
so my R package was com.aaa.bbb.R
but then added some data under com.aaa package
so my new common package became com.aaa
because of that new R position became com.aaa.R
because of that I changed
import com.aaa.R
in all classes
also i changed in AndroidManifest.xml to
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aaa" >
(previously it was package="com.aaa.bbb")
also changed in build.gradle to
defaultConfig {
applicationId "com.aaa" //previously it was applicationId "com.aaa.bbb"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
so where else I should make changes ?

The package name on the device must be unique, and there is a conflict when you try to install OVER the existing APK (that is what this means: "Failure [INSTALL_FAILED_OLDER_SDK]")
You should completely delete the old APK from your device, and you will be able to install the new version.

Related

Build Android App with Old Manifest Package Name

When I build an Android app, there's an error message shown like this
Package 'grwe.android.package' from AndroidManifest.xml is not a valid Java package name as 'package' is a Java keyword
but, I've already had an app that was published on Google Play Store before with that manifest package name,
So, what should I do right now?
I built android app using EAS (Expo & React Native)
Your applicationId does not necessarly need to match the source code.
Keep your applicationId as the published one in your gradle build file.
// build.gradle.kts
defaultConfig {
applicationId = "grwe.android.package"
...
}
Organize your kotlin/java source code in package like grwe.android.packer or grwe.android.packager
package com.example.codes
class SomeActivity : AppCompatActivity() {
...
}
Android System will launch your activity like
androidApplicationId/fullQualifiedClassNameForActivity
grwe.android.package/com.example.codes.SomeActivity
grwe.android.package/net.example.OtherActivity
Hope, it helps.

Not working with package name and firebase

I have an app uploaded to the play store. The package is: com.pathapp but then with gradle are generated two apk, com.path debug and release (without app). Now I want to integrate firebase, but I do not know what name of the app is what I have to put in firebase, if com.path or com.pathapp in order to have a well constructed google-services.json file.
If I change the original package of the directories from pathapp to path, there would be a problem?
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.00"
}
}
applicationId in the gradle is your package name.
So you need to add that in the firebase console.
In the above example, the package name is com.example. Likewise, check your gradle.
If you go to the Play Store you can see the package name of your current app. Use this, or you won't be able to upload in the store.
To see the package name is linked with your Firebase, open your project in Firebase and click on Settings, here you will see the package name of the app.
If is not the same:
-There, you can see an option to add a new app. Click the button and add a new app with your new package: com.pathapp
-Finally, you have to download the new google-services.json and add it in your project, deleting the old one if you still have it.

Issue running more than one NativeScript application on the same android device with tns run

NativeScript 2.0.0, Windows 10
When trying to run more than one NativeScript application on the same android device the tns run android command stops with message:
Successfully deployed on device with identifier '192.168.99.100:5555'.
The application is not installed.
After some investigation, I tried to install the app on the android device using adb directly:
adb "-s" "192.168.99.100:5555" "install" "-r" "<path to apk>.apk"
The command responds with the following:
961 KB/s (15394490 bytes in 15.642s)
WARNING: linker: /system/lib/libhoudini.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
pkg: /data/local/tmp/<app name>-debug.apk
Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]
After some investigation on INSTALL_FAILED_CONFLICTING_PROVIDER and found the following links:
https://issues.apache.org/jira/browse/CB-10014
https://code.google.com/p/analytics-issues/issues/detail?id=784
Install shows error in console: INSTALL FAILED CONFLICTING PROVIDER
I can say it's an ugly problem.
Researching some more, in the NativeScript project, in the directory \platforms\android\build\intermediates\exploded-aar\com.google.android.gms\play-services-measurement\8.4.0 directory there is a manifest template that contains:
<provider
android:authorities="${applicationId}.google_measurement_service"
android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
android:exported="false"/>
But applicationId is never defined, so when more than one app with this provider is added, the second one fails to install.
I have multiple NS apps installed on my phone and emulators; however when you create a new app; check to see if somehow you have ended up with the same internal name. (This can easily happen if you duplicate your prior project)
Open up your main/primary package.json file that resides in the outermost root of your project folder.
Inside this package.json file you should have a key:
"nativescript": {
"id": "org.nativescript.test3",
"tns-android": {
"version": "2.0.0"
}
},
The "id" is the underlying name of the app that will be installed on the phone. In this case; this is the awesome "org.nativescript.test3" project.
If you get duplicate id's then the the app will overwrite the each other when deployed.
There is a second reason this can happen, and the actual cause of this issue was figured out by the author of the question also. But I will stick here for any future people who might run into this so that we have a valid answer.
The author was using Google Play Services plugin, it has a AppMeasurementContentProvider that if you don't have a applicationId set in your configuration it will default to a blank id; which then means it will conflict with any other app that is using GPS that also doesn't have a applicationId set.
The real nastyness of this bug is that it will conflict with ANY app from ANY other developer who also left their applicationId blank. And so then only ONE of the apps would be installable; any other app that has a blank applicationId would not be installable on that device.
The solution is to open up your /app/App_Resources/Android/app.gradle file and we will add a new value to it.
The current version as of NativeScript v2.00 looks something like this:
android {
defaultConfig {
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
If you recall the first part of this answer and about duplicate ids; the package.json we referenced gives you the name you want to use. So in my case I would add to the
defaultConfig {
applicationId = "org.nativescript.test3"
}
So the final file should look something like this:
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.test3"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
This is related to:
Install shows error in console: INSTALL FAILED CONFLICTING PROVIDER
https://code.google.com/p/analytics-issues/issues/detail?id=784
This workaround worked for me:
in the app/App_Resources/Android/AndroidManifest.xml file add:
<provider
tools:replace="android:authorities"
android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
android:authorities="MY_APPLICATION_ID.gms.measurement.google_measurement_service"
android:exported="false" />
Where MY_APPLICATION_ID is the application's package (put it manually because __PACKAGE__ didn't work)
Don't forget to declare de tools namespace:
<?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="__PACKAGE__" ...>

Is there any way to upgrade an Android app by adding android: sharedUserId in the manifest, without uninstalling the app so the data gets persisted

In manifest I put android:sharedUserId="xxxx.xxxx.xxxx" and android:sharedUserLabel="#string/shared_user_label"
<manifest package="com.xxxx.xxxx"
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="internalOnly"
android:sharedUserId="xxxx.xxxx.xxxx"
android:sharedUserLabel="#string/shared_user_label">
In build.gradle I changed versionCode 26 to versionCode 27 and versionName "1.1.14" to versionName "1.1.15"
defaultConfig {
applicationId "xxxx.xxxx.xxxx"
minSdkVersion 15
targetSdkVersion 22
versionCode 27
versionName "1.1.15"}
When I compile and run the app it shows a popup dialog "Application Install failed" with the following message:
Installation failed with message INSTALL_FAILED_UID_CHANGED.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
Is there any way to upgrade the existing application by adding android: sharedUserId without uninstall? If yes, How?
If you want to use android:sharedUserId, Android system will not allow to upgrade app, since UID got changed
alternate option is to use contentProviders to share the data between apps

google play application upload failed

apk upload failed to the google play market.
I am trying to upload the upgraded version of my app to the google play but I am keep getting the message -
Upload failed
You need to use a different version code for your APK because you already have one with version code 1.
Your APK needs to have the package name com.corntail.project.
There is still something that is looking for com.corntail.project and it is not being found.
UPDATE:
In my AndroidManifest.xml, the relevant code is -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.corntail.main"
android:versionCode="1"
android:versionName="1.0" >
If you're using Android Studio or building with gradle, edit your gradle script (build.gradle) to change your package name and version. These values overwrite your AndroidManifest.xml file.
For example:
defaultConfig {
applicationId "com.xyz.abc"
minSdkVersion 16
targetSdkVersion 19
versionCode 2
versionName "1.1"
}
You need to change your android:versionCode="1" to 2 on the AndroidManifest...
Things you have to keep in mind when updating your application on Google Play :
Change Version code +1 depending on the old value - if it's 1 , you have to change it to a bigger number.
Change your App Version Name to something bigger / different if it's string - if your old version is 1.0 - it should be 1.1 / 1.0.1 or whatever you like (it's always a better option t have some version name strategy, if it will contains the date update addded or the revision it depends on you).
And if you want to be able to update your app, don't change project package name! That's how android system knows that this application is different than that one. If you change your package name, it's now acting like a new app and you won't be able to update it from Google Play Store! To change your package name to com.corntail.project first you need to change it in manifest and after that in your project's main package and you need to keep track of your activities, if you declared them with package name too. For example :
if your MainActiivty was declared in manifest like :
com.corntail.main.MainActivity
you need to change it now to be like :
com.corntail.project.MainActivity.
You need to use a different version code for your APK because you
already have one with version code 1.
You must change your version code in your androidmanifest.xml
Every time you update your app change this variable in you XML file:
android:versionCode="1"
You are getting 2 errors.
The Version Code: you always need to set a higher number in the versionCode and always use an integer number. (don't use 1.1)
android:versionCode="1"
The package name: it has to match the same string that you used in the latest version that you upload. So instead of package="com.corntail.main" you should use:
package="com.corntail.project"
After modify the AndroidManifest.xml save it and then search in the folder src the package called "com.corntail.main", right click, Refactor > Rename, and the new name should match what you put in package (in this example you should call it: 'com.corntail.project') and you are done!
Good luck!
You have change version code in increasing order i.e. 1,2,3...so on as every time you uploaded. In every upload version code should have greater number than previous upload version code. You can change version code in APP Module Build.gradle file.
Image
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.xyz"
minSdkVersion 14
targetSdkVersion 24
versionCode 5
versionName "1.1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
If you build with gradlew, you should check the build.gradle file,
the applicationId will overwrite the package value in the AndroidManifest.xml
android {
defaultConfig {
applicationId "xxx.xxx.xxx"
}
}

Categories

Resources