error running build target module is undefined - android

I have just installed Android Studio and when I'm trying to build I get this message:
error running build
target module is undefined

Go Run -> Edit Configurations...
Check Android Application (on the left)
Select your project
In the General tab slect a module (your app)
That worked for me

Today I had the same problem, these steps worked for me:
Close Android Studio
Edit local.properties in project folder, set sdk.dir path to the original android-sdk path which eclipse uses (ie. sdk.dir=c:\Users\Foo\android-sdks)
Load project again, a dialog appears which asks if you really want to use the other path, click yes. if it still does not work, then
Close Android Studio again
Edit local.properties again and set the path back to the original path
Load the project again, the dialog appears again, select yes
My project has been loaded correctly now, maybe it will also work for others, weird problem ;-)

Click Help -> Check For Update

In Android Studio Edit Configuration section look for Android Application. Then in the module select your app name. By default if project is imported this will be DEFAULT. Change this with your app name rebuild the app with gradle build and everything else will be good to go. Hope this helps.

Try to run the gradlew.bat file. This file will try to build your project. When the execution fail will prompt you the version of building tools your sdk miss. Install this version and your project will build.
gradlew.bat calls the environmental variable ANDROID_HOME which has to have as value the path of the android sdk, See from more information,
Android Studio Path (ANDROID-HOME) not able to set?

Related

"Setup SDK" error display in new android studio 2.1.1

I just download the newest Android Studio from the developer site.
After installation I installed Android Studio, then I created new project and after project build completed, I opened my MainActivity.java file to find this error. Please refer to screenshot below:
I also downloaded Android SDK component which is built-in already in Android Studio.
Start Android Studio and invalidate cache File--> Invalidate Cache and Restart.
Rebuild your project. Try clean build. That should do. Faced a similar problem.
Tools -> Android -> Sync Project with Gradle Files
Build -> Rebuild
Incorrect installation of JDK also might cause problems. Please tell what the error is in detail.
You can try this for JDK Installation:-
On some Windows systems, the launcher script does not find where the JDK is installed. If you encounter this problem, you need to set an environment variable indicating the correct location.
Select Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.8.0_77.
Goto File -> Project Structure on left hand side click on SDK Location there you can find Android SDK Location and JDK Location. So, now locate your JDK path by browsing your JDK installation path. Click OK, Now goto Build -> Rebulid your project.
It's better to check whether the JDK path set in Environment variable by typing java -version in commmand prompt. If it is not set, set the path as DvD said in his post.
Hope this works for you.

AndroidStudio SDK directory does not exist

I am using Android Studio for a project on SVN (usually on Windows PCs).
Lately I want to run this on a Mac, it keep giving the below error:
Error:The SDK directory '/Users/AhmadMusa/Desktop/[PROJECT PATH]/D:\Android\sdk' does not exist.
Please fix the 'sdk.dir' property in the local.properties file.
I already put the SDK on local.properties file as:
sdk.dir=/Users/AhmadMusa/Library/Android/sdk
I don't know why it keep adding the (D:\Android\sdk) automatically, this is my Windows PC SDK directory, but why it is here now! nothing on code mention any D:\Android\sdk.
Right click your project and select 'Open Module Settings' under SDK Location put your location for your SDK.
paste in /Users/AhmadMusa/Library/Android/sdk
Clean and rebuild your project
Update
Try to delete your local.properties file and create a new one, but do not check it into version control.
Right click top level of project and Create new file 'local.properties'
then add: sdk.dir=/Users/AhmadMusa/Library/Android/sdk
Clean and build
I finally find this file on the disk.The 'local.properties' file in The Android studio is not which you modify.see the picture,so you can modify this line 'sdk.dir' to your dir of sdk.Remember not in the android studio.
This is a problem when you open the project incorrectly. open the project do not import the project
Create or edit file local.properties under android directory
For window path should be like this
sdk.dir = C\:\\Users\\user name\\AppData\\Local\\Android\\sdk
For linux system path should be like this
sdk.dir = /home/user name/Android/Sdk/
Open your project folder
open local.properties in notepad++
change sdk.dir to C:\Users\xxxx\AppData\Local\Android\Sdk
save
After edit, resync again android studio.
I solve this problem, the reason is: You downloaded other's projects. His local.properties file content is his SDK path. You must replace SDK path with your local SDK path, then rebuild the project.
From Android Studio 1.0.1
Go to
File -> project Structure into Project Structure
Left -> SDK Location
SDK location select Android SDK location (old version use Press +, add another sdk)
Change the sdk path to /Users/AhmadMusa/Library/Android/sdk
I solved this issue in Windows using this format for the full path:
sdk.dir=C:/Users/xxxx/AppData/Local/Android/Sdk
I think you should go to:
File ->Project Structure->SDK Location->
there select your sdk location.
Just open your local.property file
if your project is used in mac before, so the sdk path will be something like
sdk.dir=/Users/siddharthyadav/Library/Android/
Now if you are trying to use that in windows so just edit and put your sdk location:
Example:
sdk.dir=D:\software\android-sdk\android-sdk
Just clean and build. See it works!!!
Just close your project and re-open it again.
Than SDK message appears click ok.
Today upgraded to Android 3.3, which broke everything for me.
This one was related to importing the project, not opening it.
Solution which worked for me, was to import the project. During the import it detects that the SDK directory is missing and proposes to open it from a location which actually exists. It worked in my case but your case might be different.
Many other changes still needed to be done to make old projects work. What a pain any update is. I wonder why don't they do a thorough QA first before releasing these updates. It has become an industry norm to release problem filled software, probably thinking that users will figure out solutions via Stackoverflow.
I had the same problem. Just open the project main folder. and then close and reopen the project sub folder app.
In my case, my project is located inside another Android project.
Therefore, I opened the local.properties of the parent project and fix the sdk.dir's path there.
Select SDK Location: File->Project Structure->SDK Location->
Close Android Studio.
Remove .gradle and .idea folders, local.properties, all .iml files in the project: <module_name>/<module_name>.iml
Open Android Studio and select Open an existing Android Studio project
Select path to your project
This way must to help.
Checkout your SDK manager in Android studio, if you have partially installed sdk. Install SDK completely and try running your code.
I had a ; in the environment variable name, put it out and it will works !
refollow the steps after the verification of the ANDROID_HOME
react init
=> run you emulator
=> run-android
sdk.dir didn't work for me because I had ANDROID_HOME environment variable with wrong path. So, solution is just to update ANDROID_HOME or remove it to use local.properties.
Android Studio restart is required after the change.
I faced the same problem - it was solved by only the following step.
I deleted all created .idea and .gradle folders.
It is the path problem I faced while loading source in SDK, I think.
If you have set the ANDROID_HOME variable, just remove or comment that line in local.properties file. It is the solution for me
in latest Android Sudio 3.2.1
1- you will see two files with the name 'local.properties'
2- one will be inside folder named 'app' ( app level folder ), Only if you have not yet been able to sync your project. if you cant see it in the folder strucrure in Android studio then physically find this folder in Finder . (right click and reveal in finder in case you use a MAC machine). Make changes here.
3- and other will be inside 'gradle script'
make sure you have same path there . Also make changes here (if you can see this file)
Basically find this file at its physical location in the project folder (physical location ) and make changes
eg. : sdk.dir=/Users/Rakesh/Library/Android/sdk
in both the files .
My solution: open app on Android studio.
Check sdk and clean App, after rebuild I had fixed this problem by following suggestions of Android Studio.
finally run app with react-native run-android/ios
This might due to merge conflict same as mine, try to change local.properties for me it was wrong location for android sdk as it was override from other machine
ndk.dir=/Users/???/Library/Android/sdk/ndk-bundle
sdk.dir=/Users/???/Library/Android/sdk
then rebuild
If your project is a subproject, the problem may lie on the parent local.properties file. I may suggest you to go up in the project hierarchy to the root file and execute the following command:
$ find . -type f -exec grep -l sdk.dir {} \;
That would work on OSX and Linux, if you are in Windows you may need to install Cygnus tools or something akin (I don't use Windows, so I cannot be more precise). If the path is wrongly set in some file, you'll find it with that command, then it is just a matter of opening the file with a text editor and replacing the wrong path with the right one.
My scenario is I open the project, and the local.properies shows my sdk.dir.
But it keeps telling me it need the sdk from the previous other user's dir.
So I close the project and re-import the project, and everything works fine.
Choose one of the options-
OPTION A
Delete the 'local.properties' file in 'Gradle Script'
Create new 'local.properties' file there
Paste this into your new 'local.properties' file
sdk.dir=/Users/uttam/Library/Android/sdk
OPTION B
copy the 'local.properties' file from your any old project.
paste this in your new project, you will be asked confirmation, choose 'replace'
HAPPY CODING :)
Fix the root cause. If you check the other answers they suggest to find the SDK location property and fix that. Assume you have that correctly set, otherwise you won't have any SDK components downloaded on your system. Then something in your environment is telling AndroidStudio where to find the sdk.dir. Since AndroidStudio will create this local.properties file for you, it is likely first checking the stored property of "Android SDK" System settings for this location. It should use this value in the local.properties. If you find that it still gets the wrong value, the root cause is that AndroidStudio fills the sdk.dir property from ANDROID_HOME, found in the host system environment. Fix this and it fixes the problem. You will need to (1) correctly set ANDROID_HOME or unset the variable for ANDROID_HOME (2) remove the existing local.properties (3) restart your AndroidStudio.
You need to change sdk.dir='...' in local.properties file as per your sdk location.
For checking sdk location, open File -> Project Structure -> SDK Location. If sdk location is also not correct there, you can also update it.
Go to your project_folder/platform/android/
Open local.properties in your text editor
Change URL with your SDK URL
sdk.dir = C:\Users/Pcesolutions/AppData/Local/Android/Sdk
Now run your command in windows
Its worked for me. I think, it work's also in your PC.

Errors running builder 'Android Resource Manager' on ADT

I am facing a problem when I try to create new android project in eclipse adt plugin tools.
ERROR/EXCEPTION::
Errors occurred during the build.
Errors running builder 'Android Resource Manager' on project 'test'.
java.lang.NullPointerException
I have faced this problem two times previously. Only solution was to re-install Windows operating system which actually did solve the problem. But I want a real solution without re-installing Windows.
Switching to a new workspace worked for me.
File-> Switch Workspace.
found a better solution. in the create project wizard. don't create an activity in the wizard. just untick create an activity and just create the activity manually in the manifest.
I guess you upgrade your java to java7u55.
because I am using mac, but, FYI
I solve this by edit eclipse.ini, force the ide to use java 1.6
-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java
you could try the same.
In my case, the error was solved by changing the workspace folder permissions with chmod 777.
I am using Mac OS X and downloaded the ADT bundle for Mac.
If you close eclipse and then look in your system processes and still see adb running, then that's the problem - it crashed. In my case it was because I have extension files for other programs in my JRE that the adb doesn't seem to like. Remove all your ext files, force shut down your adb.exe and then restart eclipse.
Root exception:
java.lang.NoClassDefFoundError: org/apache/log4j/Priority
Usually this means that they have one more time introduced a bug.
The "magic passes" that may help or not help are:
Pressing F5 (refresh)
Updating Android, Eclipse and ADT (knowing that you do have such a problem, I myself definitely will not do any such updates in the near future)
Creating a project from the command line, building it and trying to import
If you have any project that already works, you may try to take files from that project.
Read the logs, they are usually more informative than just the last 30 lines, but on Windows you will have to either configure the screen buffer height to be about 300-600, or redirect the output to a file.
Clean and build again.
You usually get this after an SDK/ADT update.
Go to your SDK manager and ensure that there are no updates. Then in Eclipse go to Help > Check for Updates and install any updates it finds.
Restart eclipse and hopefully it should all work.
Failing that uninstall Eclipse and re-install Eclipse and the plugins again should fix it as well, no need to re-install your whole PC.
I use maven to build and integrate android projects with jenkins/netbeans. For editing android resources, I often use Eclipse because of the ADT plugin and better android resources support.
Eclipse (Kepler) has serious problems when you import maven-based android projects. It expects the project.properties file in the root folder and will NOT generate it on its own no matter what. Example content:
# this file is needed by eclipse (adt plugin).
# Project target.
target=Google Inc.:Google APIs x86:19
Additionally, create a sym link called "gen" pointing to target/generated-sources/r if using maven to build the android project on the command line. That way, you should be able to do "File->Import...->Existing Android Project". You get an error message, but it didn't matter in my case.
Additional hints in case you have problems with m2e-android plugin:
always check that the output folders for source dirs and resource dirs are correct.
check that source dirs are set as source dirs (you usually get a corresponding warning)
if resources from dependencies are not included in the final apk, check the filter settings for your resource dirs
you may need to "import maven project from existing sources" before importing it as android project from existing sources.
make sure dependencies are imported into the workspace and open and referenced (project props -> android -> add lib)
eclipse adt does not support aar libs, use apklib instead
It can happen if you are changing the location of files that your
eclipse project uses.
In that case you can copy the files directly to your resources folder inside the workspace instead of linking them with "import"
These simple steps put me out of this trouble -
In Eclipse, Help menu -> Check for Updates.
Select all Android related plugins.
Click Next, Accept the agreement page then proceed to install the
plugin.
Make sure your java path points to the java SDK bin directory.. make sure you have installed the latest JDK t be safe..
You can also try one of these:
Close and open the project in Eclipse
Click right on the project and choose: Android Tools -> Fix Project Properties
I beat my head against a wall for a day because of the same problem. My solution (OS X): I had a stale "java_home" definition in my profile pointing to a dead symlink, as well as old classes in /Library/Java/Extensions. I removed the definition and symlink, along with two classes in Extensions (ActiveMQ and Geronimo, FWIW) and the problem went away. Not sure which step was the actual "rectifier" but if any of those conditions apply, you might want to check them.
I faced same problem on my New Macbook Pro so I just Downloaded JDK and installed it and problem fixed.
I was experiencing the same issue - I refreshed and updated Eclipse and Android plugins and was still seeing the NPE. What worked for me was changing the order of operations.
In order:
1. update Eclipse & Android plugins
2. after the update has completed, perform the F5 Refresh in the current workspace
Make a copy of your project in Explorer/Finder. Delete the project in ADT/Eclipse. Import the project again using Eclipse. Project/Clean then build. This works for me.
I have tried every solution I found on the web and they did not work.Then I remember java version on my Mac was 1.7 and I have installed subversion version 1.6 and the problem occured after that installation.Also I have deleted eclipse and used a clean eclipse and Android sdk installation I still got the problem, then I uninstalled the JDK 7 as it is told in here http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html and my problem is solved.
I have several projects in my folder. Every time I start a new one I close the others. I got this error because appcompat_v7 was closed.
Right click on appcompat_v7 and select Open Project.
This solved my problem.
Solved after changing a setting in eclipse.ini. I am using OS X 10.11.4 and Eclipse Mars 4.5.2.
Go to the folder of Eclipse.app in Finder.
Right click to open a menu, and click Show Package Contents.
Go to /Contents/Eclipse.
Open eclipse.ini in your favorite text editor.
change -vm path like below:
BEFORE: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/bin
AFTER: /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre/bin
reopen Eclipse.
enjoy :D

could not find apk in android

I am using spring and maven plugins in eclipse but when i want to run this project it returns Could not find ShopZilla.apk? How this will resolved, Please suggest me.
Make sure after updating your android sdk sdk build tools are updated properly. You can check it by Open sdk manager -"Android Sdk Build Tools" status must be installed. if the status is not installed then install Android Sdk Build Tools for the same.
If you have got all required plugins installed (ADT, M2E and M2E Android), the apk should be automatically generated by IDE.
Sometimes the apk file is not generated simply because there are some android build error in your project, unfortunately, these are not compile error so they are not shown in Eclipse problems view. For example, if you attach a icon.jpg file in your res/drawable folder and change the extension to png, you get no compile error in problems view, but if you then manually delete the apk file in your project output folder, the apk file will not be generated again and in this situation Eclipse only gives very generic message "could not find *.apk file" in console view, when you trying to run it on emulator.
Now the only question is how can we tell if there are android build error. right click your project, choose Android Tools -> Fix Project Properties. in my jpg/png example, Eclipse will show "libpng error: Not a PNG file, ERROR: Failure processing PNG image C:\android-sandbox\source\yourproj\res\drawable-mdpi\icon.png" and project marked as a error in package explorer view. as soon as you replace icon.jpg with a real png file, bingo, apk automatically generated. Though I am not sure if this can detect all subtile android build error.
If you are using the ADT plugins greater than ADT17 then rename your "lib" folder to "libs".
Then Right click on project => Android tools => Fix project Properties => Clean your project
If still issue then just restart your eclipse. Your issue will be gone.
Please follow these steps; this might help you out:
Go to Project->Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
or
projects -> clean

Android HelloWorld Build Path error

On my Mac I installed Eclipse, the SDK and created a new project, then hit build expecting to see my first helloworld app.
I got the error "the project cannot be built until build path errors are fixed".
After going thru all the path-like options in Preferences, I noticed that on the tab "Java Build Path" the "Google APIs [Android 2.2]" option did not have its check box checked.
Checking it made the problem go away.
It works now and I can see the app in the Emulator
Have I not set up my environment correctly? I used all the defaults in Eclipse and the Android SDK.
On the Eclipse menu: Project->Clean, then clean you project.
Check off the Java Build Path for all boxes.

Categories

Resources