Trying to convert projects that werent built using Gradle - android-studio

I have tried to clone the following repository on GitHub using Android Studio, https://github.com/AlexKang/favr.git, but I have the error:
Before this I selected build project using Gradle and then accepted anything it wanted to install. I am having similar problems with, https://github.com/mb16/RemindEm.git, where I get that
Each time I selected "create project from existing sources" and then accepted everything it suggested.
What am I doing wrong?

The projects have eclipse .classpath files in the folder. I'm guessing you should be able to import the project into eclipse.
As an alternative to using Eclipse you might want to try using a feature of IntelliJ IDEA (Android Studio's parent project). File > New > Project from Existing Sources... Then select the .project file for the import

Related

How to change File- New-C++ to Java in Android Studio

I don't know why it change to C++ because I only need Java.
How can I change to Java?
I had the same problem after importing an empty git project. Android studio did not set the project to be a Java project.
I solved this with the following steps:
create a new Java project with Android Studio
copy the generated files to another folder
clone the git repository into the, now empty, project folder
copy the generated files back into the project folder
Though the response is late, I hope this will help others with a similar problem.

AndroidStudio doesn't recognize R

I am teaching android app programming at a highschool. I found Eclipse to fragile so we are now trying out Android Studio. But a couple of students get that Android Studio with R. in red font, showing that it is not recognized.
This happened for example when the student copied the contents of my files.
It sometimes happens when you open a proyect from other sources. Just Synchronize it or press Ctrl-Alt-Y.
R.java file issues : 1) check the naming convention of images in drawable folder with size.
2) check the style of your application
In your case it may be missing style .. So upadate the style in value folder as per application .
The most common reason for this error is bad XML coding. For example using android:src="#drawable#drawable/picture" in ImageView will give you R error as it will not let R.Java file to build. Its hard to trace such errors as XML file will not show any error.
Also take a look if your resources are of good quality!
Hope it helps! Cheers
Build -> Clean Project
Tools -> Android -> Sync Project with Gradle Files
and all OK!
Try adding the following:
android.enableAapt2=false
to gradle.properties and Refresh:
You can also do the following: Clean Project and Sync Project with Gradle Files.
try importing your project :
To migrate existing Android projects, simply import them using Android Studio:
In Android Studio, close any projects currently open. You should see the Welcome to Android Studio window.
Click Import Non-Android Studio project.
Locate the project you exported from Eclipse, expand it, select the build.gradle file and click OK.
In the following dialog, leave Use gradle wrapper selected and click OK. (You do not need to specify the Gradle home.)
Android Studio properly updates the project structure and creates the appropriate Gradle build file.
First if the existing project was developed in eclipse you need to import the project and then check what are the error. If your students are coping codes from your project then after coping the codes they need to clean and sync the project. If still your problem not solved try this in android studio :-
File/invalidate caches/restart.
Hope it helps you :)
Especially, for regeneration of R.Java file.
If you have tried all these options:
Clean Project
Rebuild Project
Invalidate Caches / Restart
deleted .gradle folder
deleted .idea folder
deleted app/build/generated folder
checked your xml files
checked your drawables and strings
and still face problem then check your classpath dependency in your Project Gradle Scripts and if it's, this:
classpath 'com.android.tools.build:gradle:3.3.2'
then downgrade it to, this:
classpath 'com.android.tools.build:gradle:3.2.1'
clean and rebuild it will sync your project.
I had the same issue, and the lint gave me a hand...
If you're using lint, it can help too.
In gradle.build(Module:app) add the lintOptions sub-element in android element as shown below, then lint will fix it for you!!.
android {
lintOptions {
abortOnError false
}
}
I hope it helps!!

How to create Gradle build for existing IDEA project?

I have a Groovy project in Intellij IDEA 13.1.5 that I want to build with Gradle. So I have installed Gradle itself and enabled the Gradle plugin in IDEA.
But how can I now build the project (or better: start to write the Gradle build file) from within IDEA? I have created a build.gradle file in the project's module, which is recognized by IDEA correctly as Gradle file, according to the icon next to the file name.
Beside that I don't know how to continue from there. IDEA documentation says I should open the Gradle Tools window, but I can find it in View --> Tool Windows.
Any ideas?
The best way to accomplish this while still being in the same directory is by going to File -> New -> Module From Existing Sources.. and then selecting your build.gradle.
You can create a Gradle Run configuration. To get all IntelliJ Gradle features, you need to import the project via Gradle (File->Import Project, then point it to build.gradle).

How to know whether an existing project was made using android studio or eclipse?

I have got some open source projects which I want to have a try. But I want to use Eclipse if the project was made using eclipse; otherwise I would like to use Android Studio.
So how can I know by viewing the source code about the IDE used for the development of a particular project? Is there any metadata in any file which stores the IDE information?
I believe that Android Studio sometimes includes gradle related files. That's how I would check.

Android studio no main activity, no layouts on a new project

I installed new Android Studio. I created new Project and asked the wizard to create main activity. But there were no layouts, no main activity class, no nothing. Error on trying to make new Java class files. The new project tree looks like this:
No (main/java) folder.
No (res/layout) folder.
Other words project is useless.
From what i learned is that you may be picking the "no layout" option when prompted to pick one. Try picking the basic activity and the rest of the files will show
After creating the project, you need to go to File menu and then Import Project. Then browse to the location of your project and import it. Then you will see all of these files and folders. I had this problem too, and it seems to be something that they overlooked in the newer versions of Android Studio (which is quite pathetic if you ask me).
Empty Activity
Choose "Empty Activity" instead of "No Activity",
while creating a NEW PROJECT in Android Studio.
I don't know if anyone is having the same problem right now but i solved this issue by changing the Android Gradle plugin version and the Gradle version.
For doing this you have to open the project you're having issues with and click on
File->Project Structure->Project
and there you will see the two options.
Android Gradle Plugin Version 4.0.0 and Gradle version 6.1.1 worked for me. After that I went to the file directory, right click on the package folder "com.example.myProject" and manually created an empty activity. The layout folder with my new activity was created automatically after that.
I found it's because I changed the Java runtime version before through the Android Studio plugin Choose Runtime. I changed to JDK 8 from JDK 11 then the problem occured. It worked for me to change back to JDK 11 through plugin Choose Runtime.
Try
Typing main activity (without quotes) in the search box and
Press enter.
For me it got restored. Search window is useful in finding many hidden tools quickly.
I created a new activity by right clicking on java then selected activity and the layout file was automatically written
When you open a new project, you can't select "empty project" you have to select and activity project. I just went through this had to delete my project and start a new one now everythings there.

Resources