How to enable Android permissions in Android M with out user concern - android

I am building apk with L code base , this app uses android.permission.READ_PHONE_STATE ,it is working fine in M devices also .
But when i build same app with same permission ,android M prompts for User concern ,is there any way to by enable these permission without user concern .
My app is system app .

If you want to use any new feature of Android API 23, It's not possible.
Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. This approach streamlines the app install process, since the user does not need to grant permissions when they install or update the app. It also gives the user more control over the app's functionality; for example, a user could choose to give a camera app access to the camera but not to the device location. The user can revoke the permissions at any time, by going to the app's Settings screen.
In other case you can downgrade the Android API to 22 but It's not recommended...
You should change your build.gradle from something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "your.app.id"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
to something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "you.app.id"
minSdkVersion 17
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.0'
}
Remember to compile only android library version 22 or lower in dependencies like this one 'com.android.support:design:22.2.0'

Related

Unable to download

I am making an android app (testing with a physical device running 4.4.4) and every once in a while when I fresh run it or open it if it's already installed then it shows a "Currently unable to download. Please try again later" toast. I'm not downloading anything within the app, I don't use internet, I'm not sure which files are relevant, someone let me know and I can post them. I have no idea where this could be coming from.
The only thing I can think of is possibly SharedPreference is doing something weird? I'll post my gradle at least.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.apps.andapp.appname"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.code.gson:gson:2.7'
}

My android apk can not run on android 6.0

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.aclientz.aclientzcds"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
I develop an android application in android studio.Created a signed buindle apk and install my phone (android 5.0) work perfactly but its not working in andoid 5.0+ version. How to avoid this problems, pLease give suggestion
Please Check for runtime permission if you have any permission uses camera or contact which require runtime permission (link)
or for checking purpose please set your targetsdk to 22

How can I compile the older version of google play service in Android Studio?

I had tried the new version(8.4.0) of google play service in my application. This had successful to run.
But I want to compile the older google play service.
When I change the version in Android Studio, it cannot sync successful.
How can I compile the correct older google play service. I want to compile version at lease 6.0.5.
Thank you!
Here is the build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.tina.releasemap"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:6.5.87'
}
You cannot select just a random version of play-services and hope it'll work. The only versions you can select from are the ones you've installed through Android SDK Manager inside your IDE.
To check which versions you have, you need to check your SDK dir. More information here.

Android new project no code, apk is 4 mb

I'm creating a simple pro package to unlock features in my free app.
My free app will check if the pro package is installed and unlock pro features if its installed. I created a new project, with no activity. When I pushed it the app to my device it says it's 4 mb in size. Why is it so big when theres no code? Looking at other apps with pro unlockers, they seem very small like 100-200 kb.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.dsmartapps.root.kerneltoolkitunlocker"
minSdkVersion 15
targetSdkVersion 21
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.0.0'
}
Solution:
simply removed compile 'com.android.support:appcompat-v7:22.0.0' and its now 48.00kb.
Probably has to do with the your Gradle build file. It's probably using the support library, if you have no use of it you can remove it.
EDIT:
Even so, as Jared said a single support library shouldn't make your apk size that big. You should check your dependencies and assets to see what makes up for that size.
Here's a simple Gradle file for a new project:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.edd.myapplication"
minSdkVersion 15
targetSdkVersion 21
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:21.0.3'
}
Size with compile 'com.android.support:appcompat-v7:21.0.3': around 900kb.
Size without it: around 22kb.

support:CardView minimum SDK?

I'm trying to add CardView support into my app for devices lower than Android L by adding the line:
compile 'com.android.support:cardview-v7:21.+'
I've then added compileSdkVersion and targetSdkVersion to 'android-L'
Now, unless I am mistaken, I thought that this would have built on my Nexus 5 in 4.4.4, however I get the error
Failure [INSTALL_FAILED_OLDER_SDK]
Am I missing something or misunderstood this? Full build.gradle below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.gh.app"
minSdkVersion 15
targetSdkVersion 'android-L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.android.support:support-v4:20.0+'
compile files('libs/TalkClient.jar')
compile 'com.android.support:cardview-v7:21.+'
}
While CardView and RecyclerView are both new widgets being added to the support library (and therefore will be available on API 7+ devices), during the developer preview they are limited to Android L devices only.

Categories

Resources