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.
Related
"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
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
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']
}
}
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'
}
Following a tutorial on setting up A LibGDX project and the tutorial says that in the third party section there should be a Universal Tween Engine. Mines not showing up, is there a way for it to show up? What do i have to download?
Thanks in advance :))
The Gdx-setup-new-ui-jar does not come with TweenEngine library.
There is another way of adding Universal TweenEngine. Since you are using Gradle now, so it is very easy.
just download the TweenEngine from here https://code.google.com/p/java-universal-tween-engine/downloads/list and paste it in your core/libs android/libs and ios/libs folders.
in build.gradle add this line at the end of dependencies of core, android and ios.
compile fileTree(dir: 'libs', include: '*.jar')
like this:
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
compile fileTree(dir: 'libs', include: '*.jar')
}
}
then just clean/build your project and you are good to go.
LibGdx uses gradle for dependency management.
You can inject dependency from repository.
repositories {
maven { url "https://jitpack.io" }
}
add these lines in your core module of root build.gradle file.
compile 'com.github.arcnor:universal-tween-engine:6.3.4'
compile 'com.github.arcnor:universal-tween-engine:6.3.4:sources'
For me changing:
compile fileTree(dir: 'libs', include: '*.jar')
to:
compile fileTree(dir: '../libs/tween-engine-api-6.3.3 2', include: '*.jar')
did the trick. (Obviously your file name may be different (no 2 on the end for example))