Google map does not load at all, without any error - android

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.

Related

Android Studio: Generated Release APK not working

Im trying to install an app that i ensure that is working (installation via play button on Android Studio works perfectly fine) however I got an error if I try to install via Play Store or straight via an APK file: "App not installed". This error happened on a Xiaomi Redmi note 5 and not 7 (one of them never had this app installed before).
This happens when I try to install directly through the generated APK release using Android Studio.
Build -> Generate Signed Bundle/APK -> APK -> Insert my passwords -> Select Release and check both checkboxes (V1 and V2), I've tried only V1 and only V2 and none of them worked...
Now I've tried to go to Build -> Build bundle/APK -> Build APK and it worked to install using the debug file. However I cant upload this file to Play Store.
So the problem is on a RELEASE version of the APK file. How can I fix it so I can upload it to Play Store?
PS: After tried this debug file on a third device, it didn't work either.
All 3 devices worked if I install directly from Android Studio play button though.
Here is my build.gradle (Module:app) file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.appdidier.hospitalar"
minSdkVersion 16
targetSdkVersion 28
versionCode 5
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'com.google.firebase:firebase-auth:19.1.0'
//// implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
// implementation 'com.google.android.gms:play-services:12.0.1'
// implementation 'com.google.android.gms:play-services-maps:15.0.1'
// implementation 'com.google.android.gms:play-services-location:11.6.0'
implementation 'com.itextpdf:itextg:5.5.10'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.barteksc:android-pdf-viewer:2.8.1'
implementation "com.squareup.picasso:picasso:2.71828"
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
// implementation 'com.crashlytics.sdk.android:crashlytics:2.9.7'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.sundeepk:compact-calendar-view:1.9.1'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
}
Ive ended up solving my problem by removing this line of code on the manifest file:
android:protectionLevel="signature"
So sad that Google dont have a report to debug this problem... I had a lot of trouble to find it.
Too hard to find a solution when the problem is just: "App not installed"

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'
}

Release APK not working for API 6.0 and below

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!

Gradle versions specification: using mancj/MaterialSearchBar with API lvl 27?

I am using mancj/MaterialSearchBar to set up a search bar which looks like the Playstore's one. However, I'm having some trouble with my Gradle build.
The error
build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.."
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 27
renderscriptSupportModeEnabled true
}
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:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
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'
implementation 'com.github.mancj:MaterialSearchBar:0.7.6'
}
Solution tried
I already tried to replace the implementation of this API with the following line: implementation 'com.github.mancj:MaterialSearchBar:0.7.6:27.1.1' but it didn't find it (meaning it doesn't exist).
The library (version 0.7.6) is using 3 dependencies (AppCompat-v7, RecyclerView-v7 and CardView-v7) related to the version 25.4.0.
Because you are already using AppCompat-v7 and RecyclerView (RecyclerView is included into Design), the library is going to use the version 27 instead of 25.
You only have one more library to convert from 25 to 27, CardView-v7.
If to add implementation 'com.android.support:cardview-v7:27.1.1',
this will force the library to use the version 27 instead of 25, and therefor allow you to compile.
You still need to take care by testing your app to see if its behavior is correct, as the library was not tested to use 27 yet.
use latest version
implementation 'com.github.mancj:MaterialSearchBar:0.8.2'
add this code to the the project level build.gradle file
maven { url "https://jitpack.io" }
one can substitute the conflicting version alike this (and hope it will still work with 27.1.1):
implementation "com.android.support:cardview-v7:27.1.1"
implementation ("com.github.mancj:MaterialSearchBar:0.7.6") {
exclude group: "com.android.support", module: "cardview-v7"
}

Failed to resolve: com.android.support after building gradle but my app can still be installed

I have gone through all stackoverflow examples but couldn't find a solution for my problem. I tried to downgrade mz sdk vesrion and android:support but it didn't work.
I am having the following code in build.gradle. However, whenever I try to build my gradle it shows an error: Failed to resolve: com.android.support... Anyway I am able to successfully install apk to my devices and it runs perfectly. I just don't want that his dependency will cause some error in the future.
Thanks!
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.feecollector.android.feecollector"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.navigation_menu.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:27.0.1-alpha1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'de.hdodenhof:circleimageview:1.3.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.navigation_menu:runner:1.0.2'
androidTestImplementation 'com.android.support.navigation_menu.espresso:espresso-core:3.0.2'
implementation 'com.facebook.android:facebook-android-sdk:4.36.0'
}
You are using different versions of com.android.support.
this is your code:
implementation 'com.android.support:appcompat-v7:27.0.1-alpha1'
implementation 'com.android.support:design:27.1.1'
it should be like this:
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
You have issue with gradle local setting. You can try to Invalidate and Restart cache. Click File -> Invalidate caches.
Sometimes you might even other issues with updating to new Gradle level. For this case, remove .idea and .gradle folders from Project Room and Import it again from Idea start screen.

Categories

Resources