I am trying to run an app that has a Google Maps Activity on my phone. My phone's running on Android 4.1.3 and the Minimum SDK for my project is API 15: Android 4.0.3
I just created the project on Android Studio and tried to run it on my phone. But it won't run and I am keep getting this error. Can someone tell me how to solve this?
That error probably means that you are using too much libraries. And because you are trying to use google maps I'm guessing you included everything google.
Try to just use the libraries you need.
For maps use this:
dependencies {
com.google.android.gms:play-services-maps:9.2.1
}
Reading material:
https://developers.google.com/android/guides/setup
You need to configure your gradle for multidex.
Modify the module-level build.gradle file configuration to include the support library and enable multidex output, as shown in the following code snippet:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
See more on same link which you are refering : https://developer.android.com/studio/build/multidex.html#mdex-gradle
You can also see some related question for same error:
How to enable multidexing with the new Android Multidex support library
Android java.exe finished with non-zero exit value 1
I integrate firebase in my android application. Firebase will support the google play service from 9.0.0 version . I used google play service for map in the application. When i install the app in the phones that have the lower version of 9.0.0 play service,The app won't run unless update the google play service
These are the codes that i added for fire base . And i added a json file that get during firebase integration.
packagingOptions {
exclude 'META-INF/LICENSE-FIREBASE.txt'
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.firebase:firebase-core:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
I think this documentation can help you with your problem. This link will serve you as a guide on how to set up properly the Google Play Services.
Open the build.gradle file inside your application module directory.
Add a new build rule under dependencies for the latest version of play-services. For example:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:9.2.0'
}
There is a list of Google Play services API and their corresponding description in build.gradle in the link above for you to follow.
Save the changes and click Sync Project with Gradle Files in the toolbar.
Then, that's it, you can now begin developing features with the Google Play services APIs.
This issue has been incredibly frustrating for me for the past two weeks.
Using the Android SDK Manager, I updated the following:
Tools:
Android SDK Tools rev. 24.3.3
Android SDK Platform-tools rev. 22
Android SDK Build-tools rev. 22.0.1
Android 5.1.1 (API 22):
SDK Platform rev. 2
Google APIs rev. 1
Sources for Android SDK rev. 1
Extras:
Android Support Repository rev. 16
Android Support Library rev. 22.2.1
Google Repository rev.22
This is the exact list of all the repositories that I've installed and updated to with the Android SDK Manager.
However, when I attempt to add the line:
compile 'com.android.support:design:22.2.0'
Gradle becomes stuck on addDependecies. Furthermore, when I go to Module Settings, and then to Dependencies, when I try to add a new library, the 'com.android.support:design:22.2.0' does not appear within the list!
Here's additional information about my target, compile, and minimum SDK version:
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.myandroidapplication.newtestapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
What could I possibly be missing at this point? Thank you!
You have to use version 22.2.1 as it has installed on your computer.
compile 'com.android.support:design:22.2.1'
For me, I was initially adding the support library dependency by typing it out in the build.gradle of my app directly.
I cleaned the line that I had typed and added the dependency through the android studio GUI,
Go to File
Choose Project Structure
Click on the Dependencies tab
Click on the + symbol in the upper right conner and choose Library Dependency.
Search for and add the support library in the dialog that appears
Gradle build/sync should start automatically.
Don't know why, but it works for me at least.
I have a problem with Android Studio 0.2.3.
When I run my project the build stops and appears message that says:
Gradle: Execution failed for task ':AppName:compileDebugAidl'.
> failed to find target android-18
although I have installed the SDK platform of Android 4.3 (API 18) and I tried to reinstall all the SDK. I've also added the ANDROID_HOME variable in the system variables.
What seems to be the source of this error?
I think you might not have the Android-18 sdk installed. Go to Tools > Android > SDK Manager and check to see if Android 4.3 (API 18) is installed.
I solved the problem by changing the compileSdkVersion in the Gradle.build file from 18 to 17.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
STEP 1) Start Android SDK Manager
With android command something as below,
$ /usr/local/android-studio/sdk/tools/android
STEP 2) Find API 18
STEP 3) Select Android 4.3 (API 18 ) and install packages.
What worked for me in Android Studio (0.8.1):
Right click on project name and open Module Settings
Verify SDK Locations
Verify Gradle and Plugin Versions (Review the error message hints
for the proper version to use)
On the app Module set the Compile SDK Version to android-L (latest)
Set the Build Tools version to largest available value (in my case
20.0.0)
These changes via the UI make the equivalent changes represented in other answers but is a better way to proceed because on close, all appropriate files (current and future) will be updated automatically (which is helpful when confronted by the many places where issues can occur).
NB: It is very important to review the Event Log and note that Android Studio provides helpful messages on alternative ways to resolve such issues.
Thank you RobertoAV96.
You're my hero. But it's not enough. In my case, I changed both compileSdkVersion, and buildToolsVersion. Now it work. Hope this help
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ..
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
If you had the problem, opened SDK manager, installed the requested updates, returned to Android Studio and had the problem again, IT IS RECOMMENDED TO RESTART ANDROID STUDIO befor trying anything else.
Gradle will run automatically and chances are that your problem will be over. You will very possibly be told install the appropriate SDK TOOLS package, which is found in your SDK MANAGER under the second tab (sdk's are not the same as sdk tools, they are complementary packages).
You don't even need to hunt the tools package, if you click on the link under the error message, Android Studio should call SDK Manager to install the package automatically.
Restart Android Studio again and you should be up and running much faster than if you attempted workarounds.
RULE OF THUMB> restart your application before messing with options and configurations.
Check the local.properties file in your Studio Project. Chances are that the property sdk.dir points to the wrong folder if you had set/configured a previous android sdk from pre-studio era.
This was the solution in my case.
I had the same problem when trying out Android Studio. I already had projects running on the ADT under SDK 18. No need to hack the manifest files.
Fixed by:
export ANDROID_HOME= pathtobundle/adt-bundle-linux-x86_64-20130729/sdk
If you don't have the ADT installed, and just want the SDK, it seems like a good solution is to install everything and then point Android Studio to the just the packaged SDK.
cd pathtobundle
wget http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20130729.zip
unzip *.zip
As someone else said, you may need to run the SDK Manager to install the desired packages before running Studio.
I've had a similar problem occurr when I had both Eclipse, Android Studio and the standalone Android SDK installed (the problem lied where the AVD Manager couldn't find target images). I had been using Eclipse for Android development but have moved over to Android Studio, and quickly found that Android Studio couldn't find my previously created AVDs.
The problem could potentially lie in that Android Studio is looking at it's own Android SDK (found in C:\Users\username\AppData\Local\Android\android-studio\sdk) and not a previously installed standalone SDK, which I had installed at C:\adt\sdk.
Renaming Android Studio's SDK folder, in C:\Users... (only rename it, just in case things break) then creating a symbolic link between the Android Studio SDK location and a standalone Android SDK fixes this issue.
I also used the Link Shell Extension (http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html) just to take the tedium out of creating symbolic links.
This will also happen if you have written compileSdkVersion = 22 e.g. (as used in the "new new" Android build system) instead of compileSdkVersion 22.
You can solve the problem changing the compileSdkVersion in the Grandle.build file from 18 to wtever SDK is installed ..... BUTTTTT
If you are trying to goin back in SDK versions like 18 to 17 ,You can not use the feature available in 18 or 18+
If you are migrating your project (Eclipse to Android Studio ) Then off course you Don't have build.gradle file in your Existed Eclipse project
So, the only solution is to ensure the SDK version installed or not, you are targeting to , If not then install.
Error:Cause: failed to find target with hash string 'android-19' in: C:\Users\setia\AppData\Local\Android\sdk
Target with hash string 'android-18' is corresponding to the SDK level 18. You need to install SDK 18 from SDK manager.
I'm developing an App in Android studio. And I want use a Google maps API, but I can't use UI to configure project settings. I tried some different instruction to add maps, but it didn't work. I have to modify somehow build.gradle file? Can you tell me how? Does someone have experience with that?
Thanks for every advice.
If you are on 0.2 it means that you already have Google Repository and Android Repository installed(from Android SDK: terminal$ android sdk).
One of them, has the Google Play services.
Here is a full build.gradle for your module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
}
Notice how(easily) the play services can be included.
Also gradle version is 0.5.+ so it can be auto updated!
Also another VERY important thing, that wasted me a lot of time is the minimum sdk version!
It must be 8 or above, since google play services aren't supported for lower versions!