How to change SHA1 fingerprint in an android app - google-maps

Try to design simple google map related application. App runs fine in debug mode but when i switch to release mode by recreating and changing the Google Map API Key by providing release SHA1 fingerprint and package name in App, also change the build type to release by providing proper config file.
But when i run an app get a following error
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: Google Map API Key (with release SHA1 fingerprint)
Android Application (<cert_fingerprint>;<package_name>): Debug SHA1 fingerprint;com.mycompany.packagename
i am stuck here and not able to change the SHA1 fingerprint in App to release one. Please help me in resolving this issue.

Finally i figure out the problem. Signing during the build using GUI doesn't work. So for checking the release version you need to change the Gradle as follows and sync the project.
apply plugin: 'com.android.application'
android {
signingConfigs {
debug {
storeFile file('debug.keystore')
}
release {
keyAlias 'Key'
keyPassword 'Pass'
storeFile file('C:/Users/hp/AndroidStudioProjects/project/key.keystore')
storePassword 'Pass'
}
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.mycompany.mypackage"
minSdkVersion 15
targetSdkVersion 21
versionCode 6
versionName "6.0"
}
buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
debuggable false
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
}
After checking the release version of App. Run "assemblerelease" and find the release apk in the following path \build\outputs\apk*release.apk
I think this solution works for others.
Thanks

Related

Task 'installDebug' not found in root project 'Android'

"I'm using command line to build android project but gradlew installDebug command is giving an error. Showing Task 'installDebug' not found in root project 'Android'"
My top-level build.gradle file:-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My Module-level build.gradle file is:-
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
defaultConfig {
applicationId "com.avinash.myapplication"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:appcompat-v7:25.3.1'
}
Step 1 :
Don't use react-native run-android.
Step 2 :
If you are using Windows and you don't have the file gradlew.bat (but only gradlew), download it from here or copy it from an another react-native project.
Step 3 :
In directory /android execute the command gradlew tasks or gradlew.bat tasks if you are on Windows.
Check the commands that can be used in Install tasks
Install tasks
-------------
installDevKernelDebug - Installs the DebugDevKernel build.
installDevKernelDebugAndroidTest - Installs the android (on device) tests for the DevKernelDebug build.
installProdKernelDebug - Installs the DebugProdKernel build.
installProdKernelDebugAndroidTest - Installs the android (on device) tests for the ProdKernelDebug build.
uninstallAll - Uninstall all applications.
uninstallDevKernelDebug - Uninstalls the DebugDevKernel build.
uninstallDevKernelDebugAndroidTest - Uninstalls the android (on device) tests for the DevKernelDebug build.
uninstallDevKernelRelease - Uninstalls the ReleaseDevKernel build.
uninstallProdKernelDebug - Uninstalls the DebugProdKernel build.
uninstallProdKernelDebugAndroidTest - Uninstalls the android (on device) tests for the ProdKernelDebug build.
uninstallProdKernelRelease - Uninstalls the ReleaseProdKernel build.
Use the command gradlew installDevKernelDebug.
Step 4 :
If you are using react-native, go in the root directory and run npm start or expo start if you are using expo.
In the browser go to http://localhost:19002 (or the port it says on your console).
Select the local connection and recover the value like
expXXXXXXXXXXXXXXXXXXX://127.0.0.1:19000.
Check the file on .\android\app\src\main\java\host\exp\exponent\generated\DetachBuildConstants.java and copy the value in DEVELOPMENT_URL variable.
Step 5 :
Exit Metro Bundler with CTRL+C on the console.
Step 6 :
Run cd android to enter ./android/ directory
Step 7 :
Run gradlew installDevKernelDebug or other task you listed on Step 3.
I found most of these directions on this thread: https://github.com/expo/expo/issues/4097
You might be missing the Android NDK, can try to install it using the SDK Manager of Android-Studio.
For details can refer to: https://stackoverflow.com/a/58987549/1435026

Flutter geolocator package not retrieving location

I've open an issue on the geolocator repository https://github.com/BaseflowIT/flutter-geolocator/issues/199
It entails the geolocator package not retrieving the location. They recently released a new version 3.0.0 and after that the I have had only aftermath.
I am using the correct dependencies:
dependencies:
geolocator: '^3.0.0'
targetSdkVersion 28 and compileSdkVersion 28
Flutter doctor gives me this:
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.3 18D109, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] IntelliJ IDEA Community Edition (version 2018.2.5)
[✓] Connected device (1 available)
• No issues found!
Once I call await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high); the code just doesn't return anything and I have this output in terminal:
I/DynamiteModule( 4233): Considering local module
com.google.android.gms.maps_dynamite:0 and remote module
com.google.android.gms.maps_dynamite:221 I/DynamiteModule( 4233):
Selected remote version of com.google.android.gms.maps_dynamite,
version >= 221 V/DynamiteModule( 4233): Dynamite loader version >= 2,
using loadModule2NoCrashUtils W/System ( 4233): ClassLoader referenced
unknown path: W/System ( 4233): ClassLoader referenced unknown path:
/data/user_de/0/com.google.android.gms/app_chimera/m/00000030/n/armeabi-v7a
W/System ( 4233): ClassLoader referenced unknown path:
/data/user_de/0/com.google.android.gms/app_chimera/m/00000030/n/armeabi
I/Google Maps Android API( 4233): Google Play services client version:
12451000 I/Google Maps Android API( 4233): Google Play services
package version: 15090018 W/DynamiteModule( 4233): Local module
descriptor class for com.google.android.gms.googlecertificates not
found. I/DynamiteModule( 4233): Considering local module
com.google.android.gms.googlecertificates:0 and remote module
com.google.android.gms.googlecertificates:4 I/DynamiteModule( 4233):
Selected remote version of com.google.android.gms.googlecertificates,
version >= 4 W/System ( 4233): ClassLoader referenced unknown path:
/data/user_de/0/com.google.android.gms/app_chimera/m/0000002f/n/armeabi-v7a
W/System ( 4233): ClassLoader referenced unknown path:
/data/user_de/0/com.goo`gle.android.gms/app_chimera/m/0000002f/n/armeabi
I have spent a considerable amount of time on this. I am new to flutter and know that I may be missing a small thing to make it work.
I was facing the same issue. But my app started running after adding this.
[ Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true; ]
Hope it will work.
Future<void> getCurrentLocation() async {
try {
Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
Position position = await Geolocator().getCurrentPosition(
desiredAccuracy: LocationAccuracy.best,
);
return position;
} catch (err) {
print(err.message);
}
}
All the best.
On iOS you'll need to add the following entries to your Info.plist
file (located under ios/Runner) in order to access the device's
location. Simply open your Info.plist file and add the following:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location when open and in the background.</string>
I was facing the same issue now it works, I've just added forceAndroidLocationManager: true to the Geolocator.getCurrentPosition.
Position position = await
Geolocator.getCurrentPosition(forceAndroidLocationManager: true,
desiredAccuracy: LocationAccuracy.lowest);
Hey #wagnerdelima had same challenge and l solved by the following :
Change the targetSdkVersion 28 and compileSdkVersion 28 to targetSdkVersion 27 and compileSdkVersion 27 and change to geolocator: '^3.0.0' to geolocator: ^2.1.1 as below:
dependencies:
flutter:
sdk: flutter
geolocator: ^2.1.1
permission_handler: "2.1.2"
google_api_availability: "1.0.4"
This was as a result of the caret ^, it is taking the google_api_availability latest, which is migrated to android x.
All the best !!
I was struggling with this problem for about 2 days. After that, I figured out this (Mac):
In Simulator iOS did not work anyway;
Connect an iOS real device After open iOS module in XCode as follow
Right-click on folder project
Choose Flutter->Open iOS module in XCode
On XCode, Select TAGETS -> Runner
In Signing & Capabilities:
Set the Team
Change the Bundle Identifier to a unique one (ex.:co.test.app456)
Run your app in XCode (it will work)
Close XCode and go back to your project in Flutter
Select the real iOS device and run your app
I had the same issue i.e it was not returning anything but keep fecthing location so i just changed from this
forceAndroidLocationManager: true
to this
forceAndroidLocationManager: false
Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.bestForNavigation,
forceAndroidLocationManager: false)
.then((position) {
print(position);
});
Now its working fine. The problem is in new update because in the old package it was working fine
First things first, check the device you are using and your Flutter version.
i had same issue with only one device that is Google's Nexus 6P and Flutter Version 1.9.1+hotfix.6. The problem is with the package "geolocator" because all other devices are working fine.
I recommend new_geolocation. As it resolved the issue for all devices so far.
Secondly, how i used it, the readme file here didnt help, so went through the example project on Github here, used the same methods of this example for exact results.
I hope it will help.
This solution will work, I was facing issue with Android:
Geolocator geoLocator = Geolocator()..forceAndroidLocationManager = true;
Position position = await geoLocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
print(position);
I had the same problem.
I was able to solve it by:
replacing current API key with new one
clearing out all the minor bugs in file, e.g. writing remaining #override functions, adding 'const' and 'final' keywords etc.
Try these,
it might help.
If you are using the iOS Simulator, you need to set the Location different from None in order the getCurrentPosition method returns the position:
I had this problem until I tried to set the accuracy to low. Then it worked. I believe you may need extra permissions for high accuracy location. It's funny only the low accuracy works for me, none of the others. Also, the forceAndroidLocationManager has to be set to false for it to work on my IOS emulator.
This code worked for me:
Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.low,
forceAndroidLocationManager: false)
.then((currloc) {})

Android Studio Gradle Build error - specified for property 'manifest' does not exist

I think I have a minor problem with my Gradle build files in Android Studio. Since I have no experience with them, and the few research results didn't resolve my problem, I think, that some of you guys maybe know how to resolve that issue.
At first I want to explain how I "constructed" my project in case you need this information. At first I created a fresh Android Studio project to get the project/directory structure. When the creation was finished, I closed Android Studio and checked them manually out of our SVN. The reason is not really important for my issue, but I did it to leave the project structure of my company the way it is(the Android part is just a small part of it). Instead I checked my Android Studio project in and linked all necessary files with SVN externals. So it is able to checkout and commit without changing anything in the project structure. Anyways, by creating a new project my Gradle files have been the default ones, after creating a new project. Since all necessary files have been checked out in the correct Android Studio project directories, I started Android Studio again, deleted the previously created project from the list, and imported it again. After that all my new files have been displayed. Even the new libraries are included in my Gradle build file under dependencies, as you will see.
But when I am trying to Build my project (I tried "Rebuild" and "Make project") I receive following Gradle error message:
FAILURE: Build failed with an exception.
What went wrong: A problem was found with the configuration of task ':app:checkDebugManifest'. File
'D:\Workspace\MyProject\app\src\main\AndroidManifest.xml'
specified for property 'manifest' does not exist.
This is my build.gradle in my projects root directory:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
and this is the build.gradle in my "app"-directory
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "de.giessen.advenco.key2operate"
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'
}
If you guys need more information (settings.gradle, .properties-files, AndroidManifest.xml) just tell me.
I don't know if this is important but, this is what the Gradle Console shows, before the error occurs:
Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest FAILED
Gradle is looking for the manifest at \src\main\AndroidManifest.xml, which is the default for new Gradle projects.
If you are using a different folder, you can specify a different location in your build.gradle using something like this:
android {
// ...
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}

Error:(1, 0) Gradle DSL method not found: 'android()'

What should i do to fix this issue?
I am getting this error when i ever i run my project in android studio0.9.1
android {compileSdkVersion 17
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.nearby"
minSdkVersion 11
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}}dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:19.0.0'
compile files('libs/google-play-services.jar')}
I just ran into this same error. Make sure you don't have an android block in the top-level build.gradle for the project, only in the module's build.gradle file.
This happened to me when AndroidStudio tried to import and existing, buildable Eclipse/ADT project–I had to cut and paste the android block from one gradle file to the other. I don't know if this has been fixed in more recent versions of AndroidStudio.
I ran into the same problem. My fix was adding "apply plugin: 'android'" before android block...
Hope it helps anyone.
Inspired by Ionoclast Brigham's answer I've checked both gradle files. I had android() in both of them... but instead of moving android() from the root one to module one I've just added
apply plugin: 'android'
to root one and build works fine.
in my case i had to delete these lines from the top-level build.gradle file as it's a bug in the android studio which inserts this
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
}
Solution is found here under runProguard section. In short, it says;
To update your project, edit your build.gradle file as follows:
}
release {
runProguard true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}

MapActivity could not be found. Android Studio 0.5.1

I am setting up google map v2 in Android. I am using the new technique on adding dependency using this link."Android Studio with Google Play Services"
It did nice after synchronization, clean project and rebuild project. However I could not find the MapActivity. What seems to be the problem?
Build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:4.2.42'
}
MapActivity was part of the Google Maps Android v1 API which is now deprecated.
Using the Google Play Services library you will use the Google Maps Android API v2 and then MapActivity is not available anymore. You need to use the MapFragment.
You can see an introduction on how to use the MapFragment in the official documentation.