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.
Related
I just tired to create my first android application and installed android studio 3.0.1 with API 27 , 26 and other necessary SDK tools but after creating a new project now I get a " Gradle sync field error " with no error number but with a 6 message error in "Message gradle sync" ... I didn't find a good solution for that .. may anyone help me ?
Note : I have jdk 1.8 on my windows and android studio uses from it and the embeded jdk is uncheck !
This is the screenshot of my problem !
As you removed the Expresso Dependency from Build.Gradle
you need to remove the Testclass also. Because method in that ApplicationTestClass needs that dependencies.
Try deleting your test class.
java->your_package(androidTest)->delete the files here**
Also add in your Build.Gradle(Project : ) //First one
allprojects {
repositories {
google()
}
}
Check build.gradle replace classpath with -
classpath :'com.android.tools.build:gradle:3.1.0-alpha02'
check- compileSdkVersion 26
buildToolsVersion '26.0.2'
3.update all libraries build.gradle -compileSdkVersion 26
buildToolsVersion '26.0.2'
In my Android Studio project, I've added a java module that produces a JAR file which is used by the main module. I understand that Gradle rebuilds all modules on each compile process, but it is clear that it is not needed for java modules if there is no changes since the last build.
So I want to prevent gradle from building my jar file if there is no code changes in the java module, I cannot find such option
Any help is appreciated.
there're two steps to achieve what u want:
Ask the android plugin to pre-dex the libraries.
so you add dexOptions inside the android bracket
android {
dexOptions {
preDexLibraries true
}
}
and the other step is to make your debug build to be minSdkVersion 21, that way the system will build as a multi-dex application so it won't need to merge your dexed library into the APK.
There's a whole section on the dev page about it https://developer.android.com/studio/build/multidex.html#dev-build, but what you want to do is add productFlavors inside the android bracket
android {
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion YOUR_APP_MINIMUM_HERE
}
}
}
I have this problem with my emulator, i'm using API 5.1.1 and i have the lastest version of Google Play Services from SDK Manager.
AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
In the build.grable:
compile 'com.google.android.gms:play-services:+'
Navigate to settings--> apps in your emulator and then find Google Play Services, check the version number and use it in you build.gradle
Hope this helps
Change the SDK in your emulator to v21 or lower. Physical devices are not effected by this issue.
The reason Android is complaining about an update for Google Play services is related to a known issue in Android emulators for API v22 and up (at this time 23). https://code.google.com/p/android/issues/detail?id=176348
You should try to use the latest version of Play Services in your build script as users are generally forced to have the latest version of this on their device.
This problem occurred when I start my application on emulator Android 5.1.1 (x86_64) - API 22. I have read some discussions about it, but no one from them helped me.
I tried to adjust version of Google Play Services in gradle build script (I mean you should update the script with "app" name). Don't forget to sync gradle when you update something in your script.
My gradle script "app" after updates:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.itmm.map"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services:9.0.0'
testCompile 'junit:junit:4.12'
}
Please, have a look into dependencies section. You're interesting in the follwoing line of script:
compile 'com.google.android.gms:play-services:9.0.0'
Currently, ver. 9.0.0 helps me and everything is ok. I can see MapActivity on Android emulator. 9.0.0 is not a newest version of Google Play Services (the newest is 9.6.1), but it works and it can solve your problem, if you aren't interestion in new features of ver. 9.6.1.
I had the same issue. But I followed the following things
1) First download the latest build tools and play services in Android SDK
Android Studio -> Tools -> Android -> SDK Manager -> SDK Tools -> Android SDK Build Tools -> Install them
& install Play Services by following same steps
2) Create a new emaulator with latest api level for ex( API level : 28)
3) Run the app in the latest emulator
It will work fine.
I downgraded the SDK from 5.1 to 5.0 and it's working.
Your build.gradle has this line:
compile 'com.google.android.gms:play-services:+'
This means that android will use the latest version of Google Play Services when ever the app is run. The emulator might not have all the latest updates so the app will not run. Updating Google Play Services will help.
My issue was resolved after logging in with an google account on the emulator. The 'update' button worked after that
Encountered the same problem on Android Studio 2.2. What I did was to go to SDK Manger -> Launch Standalone SDK Manager, uninstalled Broken Intel x86 Atom google_apis. Restarted Android Studio and ran the project, a popup asked Download System Image, hit OK to continue, the problem then went away.
Since I haven't seen any working solutions in 2020. There are two ways to fix this:
Easy way is to create a new emulator with PlayStore Enabled. Check before downloading system image for the emulator.
Hard way is to to install Google Play Store on the emulator manually and make the update button work. You can refer to the installation part here.
After that, the app will automatically update the Google Play Services in a few minutes. That's all.
Note: If that doesn't work, Go to Chrome -> Search for Google Play Services and open the playStore link of that app and update it there.
Check in your SDK settings if youve installed google play services:
Android Studio--System Settings--Android SDK--SDK Tools:
Look for:Google Play Services and Google Play Licensing Library and make sure that both their status is:Installed.....if the above checklist is perfect,the next step you ought to perform is:
Open your build.gradle project level gradle and check that your gradle has:
classpath 'com.google.gms:google-services:3.1.0'
Then in your App level gradle:
Under dependencies:
dependencies{
implementation 'com.google.android.gms:play-services-auth:11.8.0'
and at the end of your gradle file:
repositories {
mavenCentral()
apply plugin: 'com.google.gms.google-services'
}
Next
Click on the notification error you keep getting in your notification bar of your emulator and sign in with your google account(existing Email Address and password)
Then try and run the app again...if you still get the error,click the notification error and try to sign in,,,keep trying until eventually the google playstore app will install and prompt you to update it.
This is the simplest process,it requires a little bit of patience but evetually it works.
Good Luck
my emulator's Google Play services version is 12.6.85
so I changed the build.gradle like:
implementation 'com.google.android.gms:play-services-maps:12.0.1'
Notes:
to check emulator's Google Play services version: go to Emulator \ Settings \ Apps \ GooglePlay services
to see available versions for the build.gradle check https://developers.google.com/android/guides/releases
I have a really annoying problem since several days, after I tried to restore a previously working Android Studio project from a backup, after getting a new computer.
I have the "cannot resolve symbol" syntax highlighting problem with the classes from Android libraries such as android.support.v7.app, android.support.v4.app, and Google Play Services, which I have included as dependencies.
But, the project builds fine and I can run the App on phone with no problems.
I have verified whether these jar files exist under SDK installation - for e.g. "\sdk\extras\android\m2repository\com\android\support\appcompat-v7\23.0.1".
My problem is quite similar to the ones reported in below posts:
Android Studio says "cannot resolve symbol" but project compiles
Android Studio cannot resolve symbol but code executes correctly
Android Studio suddenly cannot resolve symbols
I have tried all the solutions provided in various stackoverflow discussions (i.e. Sync Gradle Project, Invalidate Cache/Restart, Clean/Rebuild, Deleting gradle generated files (.gradle, build, .idea directories etc.), downgrade to lower API and upgrade etc. But, no method is helpful.
I use Android Studio 1.3.2 and API 23. All build tools, support library etc. are up to date (tried with both v22.+ and v23.+ of the libraries).
Please do help if you have any other suggestions!
Extract from my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.myapp.fun"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:22.+'
compile 'com.android.support:appcompat-v7:22.+'
}
Screenshots of the problems can also be found below. I think Android Studio is not able to import the dependent libraries for syntax highlighting, although the compiler is able to include them and build successfully.
Screenshot:
The reason is because I had a '!' symbol in my project path.
Apparently, as I learnt now, many Java programs fail due to this reason! :-)
I just renamed the path and it works fine now :-)
P.S.
Thank you #gabriele-mariotti for the gradlew clean suggestion. In fact, that helped me find the real root cause. I was not able to run gradlew from the terminal due to a RuntimeException:
Could not determine wrapper version. at org.gradle.wrapper.GradleWrapperMain.wrapperVersion
But that helped me learn about the effect of '!' symbol on paths, and to the root cause of the problem. Thank you all!
You can trying:
Open Module Settings, change the value of compile SDK version (you can choose the minimum version number)
Wait for Android Studio to finish refreshing
Make sure you have imported:
import android.support.v4.app.FragmentActivity
Open Module Settings again and you should change back compile SDK version , the original version number before you changed it.
Wait for Android Studio to finish refreshing
I had this very same problem with two libraries in our project, com.koushikdutta.ion and uk.co.senab.photoview which are used thoughout our multi-app project but are declared as dependencies deep down a library project.
The symptoms were like this:
I could perfectly compile and run the application
The IDE stubbornly refused to find the classes of these libraries and no navigation to their source code was possible, lots of errors (red bars) were associated with all classes that used them; class usages were highlighted in red, no code suggestions, you name it.
My solution is as follows: first of all, close Android Studio. Then :
cd <your-project-folder>
mv .idea/ .idea-old/
mv <projectname>.iml <projectname>.iml-old
re-open Android Studio but select the option "Open an existing Android Studio project". Wait for the project to be reparsed and enjoy perfect cleanness.
So I am stuck, I am trying to import an eclipse project to Android studio, and I am getting this error.
Error:(22, 23) No resource found that matches the given name (at 'src' with value '#drawable/item').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/joselibra/Library/Android/sdk/build-tools/22.0.1/aapt'' finished with non-zero exit value 1
I have attempted to sync project, delete build file, clean project, rebuild project, invalidate cache and restart.
I followed the direction on how to migrate to Android studio via this link among others, https://developer.android.com/sdk/installing/migrate.html.
This is what my gradle file looks like
apply plugin: 'com.android.application'
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.wtf.edu"
minSdkVersion 11
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile "com.google.android.gms:play-services:7.5.0"
}
Any help or clues would be much appreciated, thank you.
Import eclipse project in to android studio project .you can try this one
n newer versions of Android Studio, the best way to bring in an Eclipse/ADT project is to import it directly into Android Studio; we used to recommend you export it from Eclipse to Gradle first, but we haven't been updating ADT often enough to keep pace with Android Studio.
enter link description here
In any event, if you choose "Import Project" from the File menu or from the Welcome screen when you launch Android Studio, it should take you through a specialized wizard that will prompt you that it intends to copy the files into a new directory structure instead of importing them in-place, and it will offer to fix up some common things like converting dependencies into Maven-style includes and such.
It doesn't seem like you're getting this specialized flow. I think it may not be recognizing your imported project as an ADT project, and it's defaulting to the old built-into-IntelliJ behavior which doesn't know about Gradle. To get the specialized import working, the following must be true:
The root directory of the project you import must have an AndroidManifest.xml file.
Either:
The root directory must contain the .project and .classpath files from Eclipse
or
The root directoy must contain res and src directories.
If your project is complex, perhaps you're not pointing it as the root directory it wants to see for the import to succeed.