Release APK not working for API 6.0 and below - android

I just build a release APK and tried it. It works fine in all the devices that is having API of 7.0 or high. But when I tried testing it in marshmallow or devices with lower API than marshmallow, then the apk was not installed. It showed the error message App not installed. I have my minSdkVersion as 21 but still this problem happens.
This is my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.apollographql.android'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.leadershipboard"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.core:core-ktx:1.0.0-rc02'
implementation 'com.apollographql.apollo:apollo-runtime:0.4.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
Also While generating the signed APK I ticked both V1 and V2 checkboxes. Since I saw that in a solution but that didn't work.
What is the problem here and how can I resolve this?
Thanks in advance.

Do you have this app already installed on this device? Maybe you were using that same device as an emulator.
In this case, uninstall the earlier app and try again.
Also, if you have installed any app with same package name (i.e. maybe you changed the app name or tried opening some specific activity on your device), look out for all those in your applications and uninstall all of them.
Hope this works!

Related

Android how to auto increment version_code when next apk is generated?

Currently i have version_name = 1.0 and version_code = 1
I want to upgrade the version_code which is in version.properties in my app folder when i am generating an APK release of it.
Please help me?
Here is my build.gradle of my android app apk.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.dummyproject"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
never thought about such feature, may be useful... but note that there are some cases when you need to produce release-signed apk just for testing e.g. check some signing or proguard config works well. but still versionCode may be incremented, why not...
note that this feature will edit your code (should change versionCode permanently, for next +1), so for this purpose (if possible) may exist some plugin or script for Android Studio, but gradle itself won't edit own currently-executing build file. you may override this value (versionCode) for release flavor, but this will be fixed still, as every build command will set versionCode=versionCode+1 temporary without knowledge how many builds were made previously

Can't add specific items to activity_main.xml

Android newbie here. I don't know why but I can't add specific items/elements to the activity_main.xml (NestedScrollView, CardViev, Google MapView, etc). If I try to add, let's say Google MapView, a message appears that says this :
This operation requires the library com.google.android.gms:play-services-maps:+.
Problem: Inconsistencies in the existing project dependencies found.
Version incompatibility between:
- com.google.android.material:material:1.0.0
and:
- androidx.appcompat:appcompat:1.0.0
With the dependency:
- org.mockito:mockito-core:1.9.5
versus:
- org.mockito:mockito-core:2.19.0
The project may not compile after adding this library.
Would you like to add it anyway?.
Does anybody know what seems to be the problem? Build.gradle is displayed below.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.google.android.material:material:1.0.0'
}
The first of your problems is that you try to use Views, items, constants, etc, of a library that does not exist in your project, with these implementations it is more than enough for you to move forward, the problem with mockito is that you possibly implemented two versions and maybe the first version uses discontinued components, and therefore. Gradle will always look for the latest version, however both libraries need to live together, I recommend that you remove mockito 1.9.5 and try to synchronize again, I hope it was helpful , good luck!
apply plugin: 'com.google.gms.google-services'
dependencies{
implementation 'com.google.android.gms:play-services-cast-framework:10.0.1'
}

Android Studio design view not displaying correctly

I have looked at numerous sites and the suggestions provided here at Stack Overflow. Everything works fine with my Android Studio, except the design view does not display anything. I can drag and drop widgets or modify the XML code by hand and the text gets updated fine, but the changes just don't register on the design or blueprint. I have tried deleting and reinstalling the IDE, changing the SDK version, doing build--> clean, resetting the cache, and adding dependencies. Below is my build.gradle Anyone with a critical eye have suggestions? I don't know what I'm doing.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.mydrinkmixer.somerestaurant.mydrinkmixer"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Google map does not load at all, without any error

Google map is still blink and does not load. All the scripts, api key and code are correct.
The app gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.muzammil.bustracking"
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-location:+'
implementation 'com.google.android.gms:play-services-maps:+'
implementation 'com.google.firebase:firebase-core:+'
implementation 'com.google.firebase:firebase-auth:+'
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-messaging:+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support:design:26.1.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
// apply plugin: 'com.google.gms.google-services'
}
apply plugin: 'com.google.gms.google-services'
I am running app on actual Android phone , not emulator.
A lot of Thanks in advance for the answer...
I finally came to a solution.
Actually I was running the app on Android device with API level 24, while the app was using API level 26. I changed the target SDK version from 26 to 24 from File > Project Structure > app > flavors, at it worked.
Thank you to everybody helped! I really appreciated.
I think that you are using wrong API key.Not displaying usually happens because of it.
This guide is a quick start to adding a map to an Android app
Try
<uses-library android:name="org.apache.http.legacy" android:required="false" />
In manifest for it to work under the application> tag
Ensure that you have mentioned below permission in androidmanifest.xml
<uses-permission android:name="android.permission.INTERNET" />
You must have API key in your project. The key can be obtained from this link.
Also you have to enable API from GCP itself. This requires SHA key for your machine which can be generated using android studio.

How to display Map on emulator

From Android Studio, I created a Map Activity project; so, there's no custom code.
The only custom changes made was copying the URL from the google_maps_api.xml _(https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=)_ and using it to create an API key.
Android Studio: 3.0.1
Emulator: Nexus 5X with API 25
Build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "xxxx.xxx.xxxx"
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.android.gms:play-services-maps:11.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Screenshot
It seems like I'm missing something; I just don't know what it is.
Try to run in your mobile. Sometimes emulator is not able to load map properly, That's why it shows blank map without loading roots.

Categories

Resources