Android Studio can't see module after import - android

Android Studio “beta” 0.8.6
on 64 bit Ubuntu 14.04 LTS.
Problem:
When importing source code from various sources either gradle based or eclipse based in to Android Studio the source code is missing from the project view.
Screen shot post import “project” in Android Studio.
![enter image description here][1]
Screen shot of files within the project using Nautilus.
Note Nautilus clearly shows the source code, Gradle, IDE files. Android Studio shows the Gradle files only.
The event log event log:
Error running app: Module is not found
So I tried to put the source code into the project using:
Android Studio main menu → File → New Module
AND
Android Studio main menu → File → Import Module
Tried most of the possible combinations in New Module and Import Module.
All the combinations Gave:
“This Location is already imported” within the Module Wizard.
So how do I get the source code in to the project?
These problems with Gradle are beyond annoying and approaching the the R Object disaster in eclipse. Where none of the build sequences repeat with any reasonable consistency.
Thank you in advance for your help, ultra disgusted Mark.
Sorry about lack of images.

Got it to WORK!
Used the command line, terminal described at:
http://developer.android.com/sdk/installing/studio-build.html
Section of that page titled “Build the project from the command line” has instruction for all three operating systems.
C louse Android Studio, for some reason having it open interfers with the gradlew on my system anyway.
On Ubuntu Linux.
In GNOME Terminal.
Navigate to the folder containing the project.
Enter: chmod +x gradlew
gradlew is the gradle wrapper.
If your project is missing the gradlew file use the Wizard in Android Studio to make a separate project and copy the gradlew file to the folder where you are working.
The chmod +x makes the gradlew executable, need to be run once for each project.
The project Should build, if you get errors do your best to look them up and fix them.
Once I did the above and imported in to Android Studio the project worked perfect in with in the IDE and even ran in an AVD.
Beyond me how the command line works fine and the IDE cause nothing but grief and extreme aggravation (~ two days in my case).
SO if Android Studio will not import or open a project try the command line. Give that you have the proper build.gradle files (between the android plug in changing the stuff that goes in build.gradle changes as well so it a Screaming Nightmare to keep up with it).
I hope that helped somebody out. Mark

Related

How to build a AOSP project in Android Studio

I have imported AOSP code into Android Studio, on building it I am getting some internal errors but Run, Debug buttons are disabled.
The errors I am getting are:
Can anyone please help me how to resolve this error and to compile AOSP into Android Studio.
Also can anyone please help to how to convert this project into a Gradle project?
AOSP used a special format of makefile to build the whole project. If you insist build it on the IDE, you should write a plugin to index the whole makefile on your own.
Focus on something more meaningful. Review and modify the code in IDE, build it in shell, save your time.
To browse and debug AOSP use Intellij IDEA (close to Android Studio) or Eclipse.
AOSP source contains a tool to generate configuration for these two IDE called IDEGen.
IDEGen automatically generates Android IDE configurations for IntelliJ IDEA
and Eclipse. Your IDE should be able to compile everything in a reasonable
amount of time with no errors.
IDEGen README
To debug AOSP Java code take a look at this article (even though it is for Android Studio, configuration is the same for InteliJ IDEA).

Gradle sync failed in android studio

I am using eclipse for developing android applications.Its works good and I can debug and run the application.But now I installed android studio and move to creating new apps using android studio,But i get the following error
Gradle sync failed
What is gradle and how can i fix this problem, Now also I can't import my eclipse project to android studio
I had the same issue when importing my project from eclipse to android studio. I'll tell you how I fixed it. It's simple.
- Solution 1: It is possible to import your project from eclipse to android studio, but android studio version 1.2 currently has bugs with that. What I did is I created a new application with the same app name, same package name, same minimum api and all these things... Then normally, go to your app's folder that you want to import it from eclipse, and copy it's src folder and java folder, maybe asset and libs folder too if you have them, and paste it to your newly created project in android studio by going to that folder: "Users/AndroidStudioProjects/appname/".
If that's not your issue, try the other following solutions:
- Solution 2: Add this to your gradle.properties file in the project. This will just increase your android studio's memory:
org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m
You can also replace 512 to 1024 if you have enough memory in your pc.
- Solution 3: Try to close all your pc apps that consume large memory, and try that: In android studio, there is a toolbar at the top, where there is "Build" tab. Select Clean Project then Rebuild Project. Then try to sync your project again.
If you find the File Encoding Error is showed in your log when trying to sync your gradle, click on it and change the project formatting to UTF-8.
Source: https://stackoverflow.com/a/30498383/4843993
I would prefer to start solution 2 then 3 first before trying solution 1. If you still face the same issue, tell me. :)

Phonegap_java: duplicate class: org.apache.cordova.BuildConfig

I have downloaded Phonegap from CLI (working on windows7) and made a project from command line
phonegap create hello com.example.hello HelloWorld
and built it
phonegap build android
When i import project (project/platforms/android) in Intelijj and try to build it, it gives me this error
java: duplicate class: org.apache.cordova.BuildConfig
Any advice?
The steps that I did to import project in IntelliJ, after I built the application with "cordova build":
Import project
select "PROJECT_FOLDER/platforms"
Import project from external model "Eclipse"
In select Eclipse project, select all.
Import JDK and SDK (JDK 1.7 and SDK Android API 17 and 19 in my case)
Import Android Dependencies From Property Files (Add dependency helloworls --> helloworld-cordovaLib) OK.
At last this build and run without problem to me.
There are an issue with IntelliJ and Maven, maybe you can apply the same solution.
http://youtrack.jetbrains.com/issue/IDEA-94901
1.) Delete the "gen", "target" and "out" folders
2.) Revert the changes within the "ipr" and "iml" files
3.) Start IntelliJ 11.1.5 EAP / 12 EAP
4.) Open the pom file
5.) Right click -> "Maven" -> "Reimport"
6.) "Build" -> "Rebuild project"
A better workaround (tl;dr): Don't do the 'cordova build' step from the Cordova workflow (Getting Started Guide for Android)
We ran into this issue while doing Cordova training for our students. The recommended tool from developer.android.com switched from the Eclipse ADT Bundle to Android Studio, so we made the switch.
Unfortunately, you can't follow the same workflow. The Cordova 'Getting Started' guide for the Android platform spells out the commands to execute from the command line. But, they are for the Eclipse platform. One step needs to omitted for it to work with Android Studio.
One of the links above (http://www.tricedesigns.com/2013/05/16/phonegap-android-studio/) shows the correct workflow, but if you're used to the Cordova workflow, you may just assume it's the same and complete the steps in the same way. However! Omit the 'cordova build' step. Building the project (instead of letting Android Studio build it) causes Android Studio to get the error from the question.
The accepted answer above didn't work for us, because when we attempt to import the project, there is no 'Import project from external model "Eclipse"' option. This, however, worked just fine. Hope this saves you the hours we spent looking for answers/troubleshooting.

Linphone Android how to import the library project?

I am working on SIP application and using Linphone Library.
I am trying to make and run the build on the device but getting few issues
I have setup the Android SDK and NDK set up on my Mac.
Now when i copy the repo via Terminal using command
$ git clone git://git.linphone.org/linphone-android.git --recursive
And than to Makefile ran this code:
$make
and Then it show's Build Successfull.
Now i need to import this project into Eclipse and when i do this imported project (folder named "linphone-adroid") into my Eclipse it shows me alot's of projects i am confused which one should i use and if i choose all of them then it gives me lot's of errors in other's (Shown in image below)
liblinphone-android --> Ran this on Device runs fine but when i call the numbers it changes it's view and shows duration 0:00 and does not calls the numbers then i have to press hang off button to dismiss the call. (Not able to make call's)
Please suggest me how should i import this project into my eclipse and what else scripts i need to run on the terminal to make it run.
So far what i have did is right or wrong?
Yes , it worked finally.
After build using "make" command.I installed in my device using "make install". Also generated sdk using "make linphone-sdk"
And then simply imported in eclispe just like normal android project.
Without any error it worked. - thank god.
In windows8 cygwin created many issues, so i did build the code using "make" command in MAC. And then simply imported in windows eclipse. (some admin permission issue in MAC)
Note: android-ndk-R9c was failed my build. So then i tried with android-ndk-R9 without additional toolchain it worked great. Android-ndk old versions available at
(http://page2rss.com/0dc3a880ab1762303011d69d18408917).
after building the library you have to import it in eclipse
File -> New -> Other... -> Android -> Android Project from Existing Code -> Browse_your_project
Now open your application (Project which have activity) and assign linphone library which you have earlier loaded....
Right click on your project -> select Android tab from left hand side -> from the bottom library section, click on "Add..." -> you will see the listed library which you have in your eclipse workspace -> select correct one -> click "OK" -> now refresh and clean the project -> build and try to run
check complete guide on linphone android on coders hub.
As suggested by #bhavana
I was doing wrong while importing the linphone-android project into my eclipse.
The correct process is explained below-
Importing into Eclipse :
After i have made the build then now i just need to import the project into eclipse.
Step1: Go to eclipse click on File Menu then Import then select
Existing Android Code into Workspace
Hit Next and Browse to the linphone-android project folder
And Only tick linohone-android folder and Leave copy project into workspace untick
Like the below image:
And hit finish.
Now i right clicked on "linphone-android" (project name) and go to Properties and Java Build Path and then Order and Export and then reorder them as my image below and untick gcm.jar
Hit OK
And Boom No errors
Now just run it on device or emulator. (Cross check minimum target SDK matches with the device or emulator.)
The above steps worked fine for me.

Eclipse Upgrade Not Working

My Eclipse out of the blue stopped building my Android so I removed the old version and have installed Indigo. When I try to import an Android project in I get this error:
Errors occurred during the build.
Errors running builder 'Android Resource Manager' on project 'ACCUWX_HoneyComb'.
java.lang.NullPointerException
Errors running builder 'Android Pre Compiler' on project 'ACCUWX_HoneyComb'.
java.lang.NullPointerException
Errors running builder 'Java Builder' on project 'ACCUWX_HoneyComb'.
java.lang.NullPointerException
Please help!
Try removing the .metadata folder from your workspace. This holds all your configurations, even after a new install. I think if you just delete this folder, assuming everything is in place, you should be up and running again.
The 21.0.1 version of the Eclipse ADT tools has a bug that prevents a project building if you have any files without extensions in them. This is a particular problem for users (like me) using subversion which has extenion-less files.
The solution is to install the 21.1 preview version of the ADT tools and SDK manager from Google. Clear instructions can be found here and you can read all the background add your voice to the angry mob of developers here.
This happened to me today with ADT v21.0.1-543035 and it turned out to be the .svn directories throughout the directory structure. See http://code.google.com/p/android/issues/detail?id=42051
Worked around the issue by upgrading svn client and working copy to 1.7.
For me, the source of the NullPointerException problem was a host-side Junit test project that references (and tests) code from an Android project. It didn't have a project.properties file. It's not an Android project, but for some reason the newer version of the SDK somehow expects the file there. To fix the problem, I just copied a project.properties file from an Android project to the host unit test project.
I had something similar. The problem was created by having some files without extension inside the /src folder.
In my case, a branch tool, changed the encode of the file project.properties, I changed the encode to Windows-1265 and the problem was solved.
I had the same issue and fixed it by following comment number 6 in this page:
Issue 42051: Subversion folder causes NPE in PreCompilerBuilder
Let me quote the comment:
Solved it by installing subversion support packages for eclipse:
http://gan.so/VgYT
It's still a bug but...
same problem here, I closed Eclipse, manually removed any files in folder gen for the project, started Eclipse again, and made a build.
For also me, the source of the NullPointerException problem was a host-side Junit test project that references (and tests) code from an Android project. It didn't have a project.properties file. I added it and problem got fixed.
I found the solution on this website(https://code.google.com/p/android/issues/detail?id=68755)
So basically, what we should do is :
Bring up $ADT_DIR/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini in an editor. Before the -vmargs line, insert these two lines:
-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java
you can find the eclipse.ini following this
(On a Mac OS X system, you can find eclipse.ini by right-clicking (or Ctrl+click) on the Eclipse executable in Finder, choose Show Package Contents, and then locate eclipse.ini in the MacOS folder under Contents)
Upgrades did not work for me (on Linux), so I just installed IntelliJ Idea (build 123.155). Had to modify idea.sh to set JDK_HOME=/usr/lib/jvm/jdk1.7.0 (the Oracle JDK) and to select [menu] -- Run -- Run... -- Edit Configurations... -- Target Device -- USB device to make it work with the real device.

Categories

Resources