I have taken a fresh install of Eclipse and all the latest Android tools and want to use Proguard on existing project, but for now I have created a new blank one.
I have added a proguard.cfg file to my project
added proguard.config=proguard.cfg to my default.properties
Now when I try to export I get the following error
[2010-12-12 10:36:35 - ApplicationTest] Proguard returned with error code 1. See console
[2010-12-12 10:36:35 - ApplicationTest] 'C:\Program' is not recognized as an internal or external command,
[2010-12-12 10:36:35 - ApplicationTest] operable program or batch file.
[2010-12-12 10:36:35 - ApplicationTest] '-jar' is not recognized as an internal or external command,
[2010-12-12 10:36:35 - ApplicationTest] operable program or batch file.
I know it means there is a filepath setup incorrectly, question is where the heck is as I have looked through the general properties and project properties and can't see any reference to proguard or obfuscation so am stuck on what to change
Any help appreciated.
You need to define your Android SDK path without spaces. Copy&Paste from this answer by Mark:
Proguard error: Expecting class path seperator - not sure where I need to put a path in quotes
Yep, that worked for me. To put it
specifically:
In Eclipse: Window > Preferences >
Android > SDK Location
use something like
c:\Progra~1\android-sdk (or maybe c:\Progra~2\android-sdk on 64bit)
For me the path is "c:\Progra~1\Android\android-sdk-windows"
According to comments posted by a Google Engineer in thread here:
http://groups.google.com/group/android-developers/browse_thread/thread/19b96902fc20cede
*.bat file shipped with ProGuard doesn't support paths with spaces.
Having Java and Android SDK installed on paths without spaces doesn't solve the problem completely. Things can go wrong if path to eclipse workspace, temp folder or some of external JAR files contains spaces as well.
I was too lazy to re-install everything so my workaround involves making junction points on a file system.
I just reinstalled JAVA and ANDROID in the root directory instead of under their default paths in program files and it all worked
Is there not a way to specify the direct paths ourselves to the Java and Android SDK in the proguard config file?
This problem looks to be fixed in ADT 12. The following change in main_rules.xml solves the problem and should be included in ADT 12: https://review.source.android.com/#change,22791.
I can verify that downloading the fixed version and replacing the copy that comes with the sdk at your_sdk_path/tools/ant fixes this issue.
OK , now i found one way to fix this problem
1, set up the "PROGUARD_HOME" EVN PATH to \tools\proguard
2, restart eclipse
3, now it work fine!
I changed the SDK paths to the 8.3 format and changed the proguard.jar folder in proguard.bat to the 8.3 format and now all is working again!
Related
I have seen this same thing posted quite a few times, but whenever I try to import my project to my new work laptop I keep getting this error.
I have pulled the project from git (which his btw running fine on my old laptop).
Then I went to the sdk manager, downloaded all the tools, and all the SDK's available.
In the welcome screen, I went to Configure -> project Defaults -> Project structure.
Android SDK Tab says the path for projects without local.properties will be /Applications/Android Studio.app/sdk
This is correct.
Under SDKs I have all the available SDK's visible.
Project SDK is set to API 18
Yet still I get this error when trying to build my project.
Can anyone tell me where I havent looked yet?
I am running gradle 1.7 when trying to build which is downloaded from services.gradle.org
I had very similar situation (had a project on another machine and cloned it to my laptop and saw the same issue) and I looked in it.
Error message was coming from Sdk.groovy of Android gradle plugin:
https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/internal/Sdk.groovy
By looking at code, its findLocation needs to set androidSdkDir variable and there are only three ways to do it:
create local.properties file and have either sdk.dir or android.dir line.
have ANDROID_HOME environment variable defined.
System.getProperty("android.home") - I'm not sure how it works, but it seems like a Java thing.
While your Android Studio knows that the SDK is at that place, I doubt that Android Studio is passing that information to gradle and thus we're seeing that error.
I created local.properties file at the project root and put the following line and it compiled the code successfully.
sdk.dir = /Applications/Android Studio.app/sdk/
creating local.properties file in the root directory solved my issue
I somehow lost this file after pulling from GitHub
this is how my local.properties file looks like now:
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sat Feb 06 11:53:03 EST 2016
sdk.dir=/Users/****/Library/Android/sdk
I found the solution here:
http://xinyustudio.wordpress.com/2014/07/02/gradle-sdk-location-not-found-the-problem-and-solution/
Just create a file local.properties and add a line with sdk.dir=SDK_LOCATION
If none of the answers work for you which happened to me on macbook pro in one of the projects you can always try to run Android Studio with an alias command passing sdk.dir with each run:
alias studio='launchctl setenv ANDROID_HOME '\''/Users/username/Library/Android/sdk'\'' && open -a '\''Android Studio'\'''
To fix this problem, I had to define the ANDROID_HOME environment variable in the Windows OS.
To do this, I went to the System control panel.
I selected "Advanced system settings" in the left column.
On the "Advanced" tab, I selected "Environment Variables" at the bottom.
Here, I did not have an ANDROID_HOME variable defined. For this case, I selected "New..." and:
1) for "Variable name" I typed ANDROID_HOME,
2) for "Variable value", I typed the path to my SDK folder, e.g. "C:\...\AppData\Local\Android\sdk".
I then closed Android Studio and reopened, and everything worked.
Thanks to Dibish (https://stackoverflow.com/users/2244411/dibish) for one of his posts that gave me this idea.
Had the same problem in IntelliJ 12, even though I have ANDROID_HOME env variable it still gives the same error. I ended up creating local.properties file under the root of my project (my project has a main project w/ a few submodules in its own directories). This solved the error.
specifying sdk.dir=<SDK_PATH> in local.properties in root folder solved my problem.
I clone libgdx demo, can't import project. it also reminds like this.
Env:
Eclipse(Android-ADT)
window 7
so I create local.properties file at the project root, like following
sdk.dir = D:/adt-bundle-windows-x86/sdk
I hope this can help others!
Copy and paste the local.properties file from a project you created on your new computer to the folder containing the project from your old computer also works too if you don't want to (or know how to) create a new local.properties file.
I noticed that I get this error when I'm working on a new computer if I try to build from the command line first. However, if I build from Android Studio, it retrieves the SDK and creates the directory automatically. Then when I build from the command line it works.
You have also to ensure you have the correct SDK platform version installed in your environment by using SDK Manager.
If you have cloned a project from GitHub for example, and you've tried the methods mentioned here without success including:
Editing sdk.dir in the local.properties
Trying to set ANDROID_HOME environment variable
Or adding an alias as kasiara mentioned
You should try to see if you are trying to build a directory project that is a part within a bigger project, and so it may cause problems.
So load the entire project, and then run the project directory you'd like.
In my specific case I tried to create a React Native app using the react-native init installation process, when I encountered the discussed problem.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\***\android\local.properties'.
I add this, because when developing an android app using react native, the 'root directory' to which so many answers refer, is actually the root of the android folder (and not the project's root folder, where App.js resides). This is also made clear by the directory marked in the error message.
To solve it, just add a local.properties file to the android folder, and type:
sdk.dir=C:/Users/{user name}/AppData/Local/Android/Sdk
Be sure to add the local disk's reference ('C:/'), because it did not work otherwise in my case.
Today i updated my ADT and SDK to the newest revision r17. Now i can't export my apps anymore
each time i try to export a singed app i get the Conversion to Dalivk format failed with error 1.
It makes no difference if i try it with or without proguard activated via the project.properties.
I hope someone can help me.
I can't post any logs or so because it doesn't give me any output ;(
Error Message:
Conversion to dalvik format failed with error 1
Cheers,
Mike
Edit:
The folder structure:
/ProjectName/src
/ProjectName/gen
/ProjectName/assets
/ProjectName/bin
/ProjectName/proguard
/ProjectName/res
/ProjectName/AndroidManifest.xml
/ProjectName/lint.xml
/ProjectName/proguard.cfg
/ProjectName/project.properties
There are also Android dependencies:
/Users/##/ViewPagerIndicator/library/bin/viewpagerlistviewlibrary.jar
/Users/##/NineOldAndroids/library/bin/nineolddroidslibrary.jar
/Users/##/ActionBarSherlock/ActionBarSherlock v3.0/library/bin/actionbarsherlock.jar
/Users/##/GreenDroid/bin/greendroid.jar
/Developer/##/annotations.jar
/Users/##/ViewPagerIndicator/library/libs/android-support-v4.jar
And referenced librarys:
/Users/##/Project Librarys/AdMob Ads v4.3.1/GoogleAdMobAdsSdk-4.3.1.jar
/Users/##Project Librarys/SwarmLib/Swarm.jar
/Users/##/Project Librarys/heyzap-sdk-2.0.7/android-sdk/heyzap-sdk-2.0.7.jar
/Users/##/Project Librarys/google-gson-2.1/gson-2.1.jar
/Users/##/Project Librarys/Acra v4.2.3/build/acra-4.2.3.jar
EDIT
Tried to remove all libs and add them again. Tried to put external libs into the libs folder and not adding them via the properties. No difference ^^
Have a look on this: http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
It solved both "conversion to dalvik" and "class not found" for me. I just needed to restart Eclipse after the changes the link suggested.
In ADT 17, they changed both how ADT handles dependencies as well as upgraded proguard (to version 4.7) and created and separated proguard.cfg into a "global" proguard-android.txt and proguard-project.txt.
I followed the link posted by #leocadiotine (http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17), which basically says to remove all jars from your build path (and don't re-add them...ADT includes them automatically now).
I also updated my proguard to use the Android global defaults and then added my project specific proguard needs to a new proguard-android.txt (replacing proguard.cfg). Then just added
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
to my project.properties. (See http://tools.android.com/recent/proguardimprovements for more info).
That did it for me. Hope that helps.
I ran into this exact same issue at work, several member of my team updated to version ADT v17.
ADT v17 now uses every jar file located in the libs directory including files not specified in under project's java build path.
We relied on the fact that not all jars were loaded because my team was leaving old unused legacy jar files in the libs directory (as we developed a new version of a jar we left the old one in the libs directory). Of course now multiple versions of the same jar are being used, so this is what causes the error java.lang.IllegalArgumentException: already added.
Simply clearing all the specified jars from the project's build path was not a solution; it would ruin the other devs not using ADT v17. The best solution was for to move all the legacy jars out of the libs directory (which is something we should have done in the first place :P).
Update to ADT r20 solved everything
This question already has answers here:
Developing for Android in Eclipse: R.java not regenerating
(64 answers)
Closed 9 years ago.
In Eclipse, I've created a project from a source and now it shows errors - "R cannot be resolved to a variable". From what I found here, I had cleared and rebuilt the project, but still the R file doesn't appear in the /gen folder.
Any ideas?
Dont worry. First you may clean the project, then run the project. If this does not work then follow the following links:
Here is the best way to solve this problem: [Android Development- Where is my R.Java file?][2]
R.java not regenerating
R cannot be resolved - Android error
R cannot be resolved to a variable
R cannot be resolved to a variable -- mailing list entry
Fixed: R cannot be resolved to a variable
If Clean/Rebuild Project doesn't work try to check our package name in AndroidManifest.xml.
The problem "R cannot be resolved" happens when you change your package name in the AndroidManifest.xml file. It uses your Android package name to create a subdirectory under the "gen" directory where it stores the R.java file.
For me the error got fixed by making some changes in Android SDK Manager.
Whatever be the latest API level available, install its "SDK Platform". For me latest API level available was 16, so I installed its's SDK Platform as shown in the image below. It works fine now.
Cheers, Mayank
Did you just update both sdk and adt(from 21 to 22), then you need to install a new item: Android SDK Build-tools
Refer to:
Eclipse giving error, missing R.java file after recent update
For me somehow the Project properties; Android; Project Build Target was not set. I chose a Android version there (e.g. 4.2) and it fixed it.
for me, the best solution to suggest to people that have problems with the "R" file would be to try the next steps (order doesn't matter) :
update ADT & SDK , Eclipse and Java.
remove gen folder , and create it again .
do a clean-project.
right click the project and choose android-tools -> fix-project-properties .
right click the project and choose properties -> java-build-path -> order-and-export. make sure the order is :
Android 4.3 (always the latest version)
Android private libraries
android dependencies
your library project/s if needed
yourAppProject/gen
yourAppProject/src
make sure all files in the res folder's subfolders have names that are ok : only lowercase letters, digits and underscore ("_") .
always make sure the targetSdk is pointed to the latest API (currently 18) , and set it in the project.properties file
For me, there was a missing slash at the end of my SDK. In Eclipse > Preferences > Android > SDK Location
For example, change
/home/matt/android-sdk-linux
to
/home/matt/android-sdk-linux/
your android manifest must start with correct package
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="HERE - Correct package NAME"
android:versionCode="1"
android:versionName="1.0" >`
I got similar problem and solution I found out was in resources any of
the file aka background, sound etc must not contain capital letters or
any special symbol other than _
What you really need to do it just install "build-tools" from sdk manager,
and r.java will be generated automatically.
I had the same error. Error was that, I had placed a file in res/raw folder with invalid filename.
As soon as I corrected the file name to a valid one, error was resolved!
Allowed characters for naming a file:-
1. a-z
2. . _
3. 0-9
4. no capital letters
Capital letters were the issue in my case!
Sometimes you can accidentially add an import to "R", so if at the top of your code you see some weird import about that that you did not add yourself, delete the reference, and everything should go back to normal
My problem was strange and took some time to find. Somehow the package of the src file changed so that the last entry in the package was deleted. So for example initially my class MyActivity.java was in package com.abc.client.test.app but after I added a user permission, the app got removed and the package was renamed to com.abc.client.test. I don't know how it happened. Renaming the package and putting the java file in the correct place fixed the problem.
I found this problem when trying to run the Notepadv3 programme from Googles 'first lesson'..
For me it was an issue with the xml file, due to the API level I was using. I renamed each case of Match_Parent to the older type of Fill_Parent. Oh and if you have already auto-built the project then you need to delete 'import android.R' on NoteEdit.java and Notepadv3.java, clean the project (click 'Project', then 'clean...') before saving.
Solved it for me. Came from this post Android NDK r4 san-angeles problem
Can't believe Google dosen't warn of this problem - I have been setting up another PC to start programming again and even with a bit of prior knowledge this was a pain.. How do you set the API when importing an existing project??? Can't see where there is any dialogue option when you 'File' 'Import' etc ..
Scamparelli
Check the androidmanifest.xml file and layoutfolder xml files. They should be created properly as the starting and ending clause in xml should be placed properly. Update the files, clean and build. And all set!
I had this problem and none of the other guides helped, and then I realized I didn't have the java jdk installed on my system. If you haven't done this either go download the version corresponding to the version of eclipse you installed (x86 or x64)
It is possible you have an error in your *.xml files: layouts and etc.
Try to modify AndroidManifest file.
For example add space and delete this space. After this OPERATION, save project. Resources will be refreshed. It can help.
I solved the problem with resolving R resource on fc19.x86_64 and ADT v22.0.5-757759 by installing additional libraries after Fedora and ADT upgrade.
yum install ld-linux.so.2
yum install libstdc++.so.6
yum install libz.so.1
Those libraries are required by adb (Android Debug Bridge version 1.0.31).
Then restart Eclipse and perform project clean Project->Clean check project you would like to clean.
Hope it helps :)
Project > Clean...
usually regenerates R.java file located in gen/com.mypackage
In my case, R.java wasn't getting generated because of a hierarchical parent error, which in turn was cured by updated one or more Eclipse plugins (Go Eclipse-->Help-->Check for Updates)
I got this error when I added a js file to the res folder.
An error indicator was set on the res folder icon. In all the classes where I used R I got this error.
I moved the js file to the assets folder and everything worked.
Problem was eclipse was not generating R.java.
To resolve this issue please go to project->clean... and select your project and select ok and then clean and build project and import your package name R file(Ex com.demo.R). It works.
This can happen when the android naming convention isn't followed. Check if you have placed a file/photo into one of the android folders and make sure that the file name contains only lower case letters
I know this is an old question but I just solved my own version of it and perhaps this might help someone.
After two days of tearing my hair out with this, I finally got around it by deleting the raw folder, then recreating it and dropping the file(s) back in.
After that, another Project > Clean and it at last compiled.
I got this when I renamed a project. Although the project is renamed, some references are not. Clearing lint, and then rerunning lint helped. (Right click project > Android Tools > Clear Lint Markers, then Run Lint)
My setup was broken after a recent update where the SDK build tools need to be installed separately after the SDK installation. So build tools update + Eclipse restart fixed this for me.
Credit goes to the Android reply here
When other solutions fail, select your project and delete it. MAKE SURE YOU DO NOT REMOVE FILES FROM DISK.
Then use file>import>existing android code into workspace, and select the location of your project.
I been having this and i did trace it back to the layout files.. It happend to me again however i could not find noting in the layout files. I looked in the string.xml and there was it.. one of the string names started with cap and that was causing the problem.
Fix any XML formatting errors in the XML Files in your /res/menu folder.
Might be a compile time error from the XML file being improperly formatted.
Before I publish an Android app I'd like to run it through proguard. When attempting to build with progaurd I receive an error:
[2011-07-26 11:11:17 - app_name] Error: C:\Users\User\Galileo (The system cannot find the file specified)
After reading through some threads I found that progaurd won't work if the path has spaces. Well, the default workspace that Eclipse created has a space:
c:\Users\User\Galileo Workspace\
So, I went to the workspace folder and changed the name of the workspace folder from:
Galileo Workspace
to:
Galileo_workspace
...hence removing the space from the path.
When I did this, two things happened.....my workspace couldn't be found (not a big deal, just switching the workspace corrects this issue). The problem is that all of my alias information is gone. And the biggest problem of them all:
When trying to export my android projects with keystores I've created before changing the workspace, they no longer work.
How can I change the name of my workspace folder and remove the space in the path so that none of my aliases or existing keystores are affected?
In default.properties file, I was originally telling eclipse where to look like this:
proguard.config=proguard.cfg
I changed this line to tell the eclipse the entire path like this and the project was successfully built:
proguard.config=/project_folder/proguard.cfg
Anyone know why? Is it the space in the path to my workspace folder that caused the initial error or could it be my Eclipse setup?
Regarding your original problem: you should try upgrading to Android SDK R12. The problem with spaces in paths has been solved in the updated Ant configuration file (android-sdk/tools/ant/main_rules.xml; android issue 16674).
I tried #dell116 answer but it didn't work for me, but I realized that the "space" charachter in the path is the problem, so if the project that you want to export the apk for is in your workspace you may switch the workspace path to the same old one but replacing each (SPACE) with (~).
But if your project has its own path you may use Right-Click your project name in
Eclipse > Refactor > Move > then
choose another path for your project without spaces then it will move your project in the new path and every thing will be OK.
If I run my project this error will come build path problem how to solve this error.
error:
Description Resource Path Location
Type Project 'videothumb' is missing
required source folder: 'gen'
videothumb Build path Build Path
Problem
The project cannot be built until
build path errors are resolved
videothumb Unknown Java Problem
Can any one help me?
Try to clean project and if it still doesn't help close and then open project.
IF you are using eclipse then do as follows:
right click your project.
select build path-->configure build path.
update all the broken links in all 4 tabs.
Go to project-->clean [project will be found at top menu of eclipse.]
Clean your project.
Its done. For any further explanation comment on my answer.
Hope this helps.
Edit:
Here you go:
As you can see i'm at source tab of configure build path and i have only one folder here named ATalk/Src. likewise you can have number of folders.
Check for red cross mark on folder. if its there then your folder path is wrong means link is broken for that folder.
Same way you can check in Libraries tab. There you will find list of jars in your project. If any of them have red cross then its path is missing. So update all such red cross paths.
As you can see i dont have a red cross on my folder means it is at correct location.
Hope you get my point.
EDIT:
I just noticed that, according to your screenshot, the problem seems to be that the adb tool is not found. Now I might be wrong but I think that as of Android 2.3 (maybe even earlier) the adb tool is expected to be in [path-to-your-sdk]/platform-tools folder, not in the [path-to-your-sdk]/tools folder. The later path was used in earlier SDK's and your problem might be caused by such a simple thing that you have an outdated Android plugin in Eclipse.
OLD, IRRELEVANT ANSWER:
I've seen these kind of issues in Eclipse environments when I have some kind of error in my XML files. Malformed errors (that violate the rules of the XML structure) are often treated as "syntax errors" and are shown directly when you write them or when you try to build your application.
Other errors, however, like giving invalid references (giving a dimension where an integer is expected, for example) are not always highlighted with file name and failing line number (I'm not sure if this is bug in Eclipse's android plugin or even if it's a bug at all).
These kind of errors you'll have to hunt down manually and rebuild your project (as dcave555 sugested). This is really boring work if you have many XML files with many changes in
I think the path should look like this: /home/embdes/projects/android/android-sdk-linux_86
The problem is because of your Android build path settings. Try to check:
Window > Prefereces > Android > Build path
it should properly set to your Android SDK