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.
Related
Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/integration/android/IntentResult;
I have same problem with Android Studio 3.0 beta 4. I found a solution.
1. From the Build menu, press the Clean Project button.
2. After task completed, press the Rebuild Project button from the Build menu.
For Android Studio 3.0 what I did was to add this to my gradle:
multiDexEnabled true
And it worked!
Example
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.xx.xxx"
minSdkVersion 15
targetSdkVersion 24
versionCode 9
versionName "1.0"
multiDexEnabled true //Add this
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
So I solved this issue by doing the following:
Delete the ./gradle folder inside your project
Delete all the build folders and the gradle cache. I ran the following command:
How ?
cd ~/[your project root folder] && find . -name build -exec rm -rf {} \; && rm -rf $HOME/.gradle/caches/
Assuming your gradle config files are in the $HOME/.gradle folder.
Inside Android Studio, went to File > Invalidate caches / Restart... and invalidated the caches and restarted it.
You should be able to get to the cause of this error by inspecting your dependencies with gradle and looking for duplicates like this:
./gradlew -q app:dependencies
In my case, the following error was happening at build time:
Duplicate zip entry [httpcore-4.4.1.jar
and it was resolved by doing this in my build.gradle:
implementation ('me.dlkanth:stetho-volley:1.0') {
exclude group: 'org.apache.httpcomponents'
}
If your minSdkVersion is 21 or higher
android {
defaultConfig {
multiDexEnabled true
}
}
if your minSdkVersion is 20 or lower
1) you must add the following library in dependencies
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
2) Create a java class then extend it from Application and override attachBaseContext method.
public class MyApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
3) Mention the created class inside manifest in application tag.
<application
android:name=".MyApplication"
.
.
.
</application>
Check your dependencies for latest version usually it is inconsistency with the version of any of your dependencies.
1.Build > Clean Project
2. Rebuild your project
Check the verbose log for the dependency causing the merge issue and update the same. Repeat the same for each dependencies.
I faced same issue in Android Studio 3.0.1, I tried all possible cases nothing worked for me as mentioned above, finally I solved it by
Solution1:
Close Android Studio
Delete .gradle folder located at C:\Users\YourComputerName\.gradle not from app's .gradle
Restart android studio
It will download all the necessary jars and add to your build path
Solution2:
Delete duplicate jar from libs folder in app/libs
Rerun the app again
Because if there is duplicate jar file which already defined in build.gradle file it causes issue.
This solved the issue for me. It may help others..
This error can have multiple reasons.
No clean and rebuild or anythging like that did the job for me.
For me the problem was the dependency:
compile 'org.jetbrains:annotations-java5:15.0'
I removed it and everything worked fine.
Change "compile" to "compileOnly"
this is what worked for me.
In my case the culprit was SendGrid lib, added this and it got fixed:
compile 'com.github.danysantiago:sendgrid-android:1',{
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
I am using Studio 3.0.0 release. In my case there was the only solution: I have removed old JARs from the "libs" folder in my project: it was "ksoap2" package with dependencies. Packages obtained with gradle usually do not conflict with each other, at least if you are using the most popular ones. But an old JAR in libs folder may crush your build if it includes all own dependencies.
I have tried other comments from removing gradle and bla bla bla, but adding multiDexEnabled true solving my problem, I investigate that my apk has reached Over 64K Method.
Ref: https://developer.android.com/studio/build/multidex.html)
I am using
Android Studio 3.0.1
Build #AI-171.4443003, built on November 9, 2017
I delete jar file from libs folder. And that work fine for me
I am using Android Studio 3.0.1 and was facing the same problem. If others answer doesn't works try this:
Tools -> Android -> Sync Project with Gradle Files
It worked for me Sync Project with Gradle Files
Sometime it can happens due to same library (jar file) present two times or your project has reached 64k methods limit.
Solution:
1) Remove Databinding if your project use this
2) Remove same type library from lib folder or, delete .gradle file from c//user//your_pc//.gradle
3) apply this in your build.gradle
android {
defaultConfig {
multiDexEnabled true
}
}
So all the reading I've done online says to set ndk.dir in the ANT build properties file to fix the "NDK not configured" error I'm getting from Gradle, but obviously I can't do that because I'm not using ant, I'm using Gradle+CMake.
Below is my gradle script. I'm still very new to this, I'm just trying to figure things out as I go. I got the java piece building fine in Gradle but at this point I am not able to integrate CMake.
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
ndk {
moduleName "UI"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
externalNativeBuild {
cmake {
path '../../CMakeLists.txt'
}
}
}
Where can I specify the NDK path? I have an environment variable defined named ANDROID_NDK. CMake 3.7 uses this to hunt down the location of the NDK already. Why isn't the android gradle script using it? What is the proper way since I'm not using ant?
Note: I'm trying to get things building on the command line first outside of Android Studio via gradle build command. The error I get:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':Core:UI'.
> NDK not configured.
Download it with SDK manager.)
You can specify the path to the NDK in Android Studio by selecting the File->Project Structure menu item.
You should then see the Project Structure settings dialog where you can specify the NDK location.
The value you enter here will modify the ndk.dir value in the local.properties file, which you can see in the background in the image below:
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.
I can't seem to fix this error after I add a jar file to the project:
Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
The program runs without the jar file but when I add it, everything builds but it gives me this error when I try to run it. I have searched and tried the following solutions but nothing fixed the error.
why java.exe exit with value 1 in android studio
Error:Execution failed for task ':app:dexDebug'. > comcommand finished with non-zero exit value 2
Android java.exe finished with non-zero exit value 1
Since none of these solutions worked I thought it my be a over 65k method problem so I edited my build.gradle but the problem still exists.
https://developer.android.com/tools/building/multidex.html
This is my build.grade for my app project:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
................
minSdkVersion 15
targetSdkVersion 21
multiDexEnabled = true
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:21.0.3'
compile 'com.android.support:multidex:1.0.0'
compile files('libs/xyz.jar')
}
I don't know how to fix this problem. Any help would be appreciated.
I had this error message (also only when running not building) when attempting to add a plain Java module as a dependency on an Android module. Though it only happened in Android Studio, not from the command line.
I solved it by including the following line in the plain Java module's build.gradle:
sourceCompatibility = 1.7
Note that Android Studio marks this line as not used.
Try clicking on File > Invalidate caches / Restart > Invalidate and Restart. Once it builds, run your project again. It worked for me.
I guess this has to do with the number of libraries you are including in your project. Although I am not certain this will help you could put this in your gradle file:
defaultConfig {
...
multiDexEnabled true
}
But even with that I got this error after adding another library. I was lucky that one lib was not crucial for the app, it was a library for catching memory leaks, so I removed it and then it compiled. As I am not an expert here maybe someone can add something to this topic? I will try to find out more about this 65k limit and how to overcome it and will get back to this.
I resolved this error by switching the JDK location of my android studio project. Just right click on the project root directory select Open Module Settings, under the sdk location option, browse the JDK location to a different one if you have 2 or more installation as in my case there were:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
and
/Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home
For me, I open SDK Manager, and update all the package that could be updated, and restart my MacBook, then it works.
I am wondering if it relevant with my updated OSX, coz I updated it to 10.10.4 yesterday, my project was good but crashed after, anyway, try to update all the things you could do, even re-install java.
Good luck!
The error comes from you running a Java 8 SDK instead of a Java 7 SDK (which at the time of this writing seems to be required for Android Studio).
I installed Java 7 from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html and pointed Android Studio to use the Java 7 JDK by going to File > Other Settings > Default Project Structure... (Android Studio 1.3)
Now everything works just fine!
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.