How to increase the compatibility of the apk - android

I am making an app and the apk file that I am installing on my phone(API 23) using USB is not supporting on other devices(I have shared the apk and try to install it on a device of API 25).But another apk can be installed on that device using USB which is again not supporting on my phone.So,the apk of my app is not compatible.
And one more thing,the layouts are becoming different in different devices and sometimes 2 images are overlapping in one while in another device it is completely fine.
So I want to increase the compatibility of my app. Please help me out.
My manifest.xml file:
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ankush.anthroplace.anthroplace">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".AboutUsActivity" />
<activity android:name=".TestimonialActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".RegisterActivity" />
<activity
android:name=".ServicesActivity"
android:label="#string/title_activity_services"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".FormActivity"></activity>
</application>
</manifest>

Check the API level you are targeting on your project.
If you're working with Android Studio, look on the file "build.gradle (Module: app)" and change the "minSdkVersion" attribute.
The lower the number you set on that attribute, the more compatible will be your app, but you should loose some features as well.

try to put minimum sdk API level 19.
by targeting minimum apk level 19 your app will run on approximately more than 90% of android devices.
and compile your app with the latest build tool
you can change minimum sdk version from build.gradle file
android {
compileSdkVersion 26
defaultConfig {
applicationId "profile.com.demotest"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Check Android Dashboard you will get better idea about choosing minimum api level

Related

Android release build failing but debug version builds OK

I'm working on a small Android Wear OS app and am pretty close to a release version.
The app is built in Android Studio using the Wear OS application template and it currently has just the one Activity (MainActivity).
Up to now I have been building a debug variant without any problems. I didn't need to tweak anything to make that work.
But now I am trying to build a release variant I am getting the following error:
Error: MainActivity must extend android.app.Service [Instantiatable]
My AndroidManifest.xml is as follows and it's the <service android:name="MainActivity" that is flagging as the error in the editor with MainActivity underlined in red:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.DeviceDefault">
<uses-library
android:name="com.google.android.wearable"
android:required="true" />
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<!-- Recommended for Android 9 (API level 28) and lower. -->
<!-- Required for Android 10 (API level 29) and higher. -->
<service
android:name="MainActivity"
android:foregroundServiceType="location" >
<!-- Any inner elements would go here. -->
</service>
<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>
</application>
My MainActivity currently extends Activity
public class MainActivity extends Activity {
I have no idea how to resolve this... it doesn't make sense to me that the debug variant builds and runs fine but the release variant doesnt.
The only release build specific stuff in my build.gradle is:
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
When I switch back to the debug variant the app build and runs perfectly on both an AVD Wear OS device and on an actual device.

My app is not installing in signed apk mode

I have developed a android application . which is about maintaining the house . i have work with firebase in that application. now the problem is when i install that app in my android phone via usb cable from android studio it's run perfectly. but if i want share the app with someone via share it it's not working. (app not installed) a error come, why . ?? even if i am generate signed apk from android studio then it's also showing the same error . why ? any solution please.
and here the manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sonalirod.alwayswhite">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/lastfinalw"
android:label="#string/app_name"
android:roundIcon="#mipmap/lastfinalw"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Firstscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Login" />
<activity android:name=".Interface" />
<activity android:name=".MainActivity" />
<activity android:name=".Bazar_Data_Input" />
<activity android:name=".MealEntry" />
<activity android:name=".Suggestion" />
<activity android:name=".admininterface" />
<activity android:name=".ALogin" />
<activity android:name=".AdminloginEnter" />
<activity android:name=".Showalldeposit"></activity>
</application>
</manifest>
gradle settings
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.sonalirod.alwayswhite"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
and i am trying to install in android 4.4.2 (api 19-20)
CommonsWare explained it all.
https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
Distributing APKs outside of GooglePlay to users need then to accept installing from Unknow Sources.
This options is under Settings > Security.. "Unknow sources"
Based in the link form other answer:
"
Android Studio 3.0 sets android:testOnly="true" on APKs that are run from the IDE
For many developers, this is of little consequence. However, if you have ever taken an APK lying around your build/ directory and sent it to somebody, that will only work if you did something other than run the app in Android Studio in order to create that APK, such as:
Built the app using the “Build APK(s)” menu option
Built the app using the assembleDebug or assembleRelease Gradle tasks
Built the app using something else that might use those tasks, such as a CI server
"
Are you building the application as release right?

You need to use a different version code for your APK because you already have one with version code 8

Please wait before marking the question duplicate. I already have seen all related question. but I can't figure out the problem. this is old version:
minSdkVersion 14
targetSdkVersion 26
versionCode 8
versionName "1.5"
and this is new version code:
minSdkVersion 14
targetSdkVersion 26
versionCode 20
versionName "2.0"
I am using android studio version 3.0 beta 6
and to solve the problem what I have done already.
1. Invalidate Cache/Restart
2. Clean Build and Rebuild Project
3. Tried with different apk version code and version name
4. Disable instant run
and here is app's manifest file:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:name=".App"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTop"
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
About an hour later I am able to solve my problem. I have just signed my APK with android studio 2.3.3(latest stable version). And it worked.

Problema updating and uploading my apk

Hi guys this is the first update I make to my app... I was reading and noticed that I need to change the versionCode and versionNameof my app in the manifest.xml, I did this and click on Build-> Generate Signed APK then in the developer console select my app and in the left menu click on APK then upload new APK and select my new generated APK but I keep getting the same error:
Upload error You must use another version code for your APK because
you already have a file with the version code 1.
BUT I don't know why I'm getting this error this is my manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ve.net.gorydev.bachaqueofamilia"
android:versionCode="2"
android:versionName="1.1">
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
what should I change?? remember this is my first update
The versionCode and versionName are also defined in your app/build.gradle; define them there and you should have no problems.
android {
defaultConfig{
versionCode 2
versionName "1.1"
}
}

uses-sdk is missing in manifest

i am following the Training section of developer.android.com where i can read :
One of the most important elements your manifest should include is the
element.
But, the automaticaly generated manifest i have is :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.david.myapplication" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.david.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>
Where i can't see any .
Must i consider it as normal behaviour ? Must i add this by myself ?
May be usefull : i am using AndroidStudio instead of Eclipse/ADT
Android Studio uses the newer Gradle-based build system. Its manifest merger creates the actual manifest for you, based on the information in the AndroidManifest.xml files and build.gradle files.
In particular, the uses-sdk information is usually derived from build.gradle.
For android studio, the compile sdk version is in the build.gradle. like this:
defaultConfig {
applicationId "com.eyespage.sdk.accounts"
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
so you don't have to include it in manifest

Categories

Resources