Search code examples
androidandroid-studioandroid-studio-2.0

Importing src folder into Android Studio


My Android Studio project was doing some funny business with the preview mode. I was getting lots of errors in regards to rendering the views. In just one Activity I would get about 50 errors. Long Story Short: I spent all day searching for a solution to no avail, but noticed that these errors only happen to that particular project. I thought - you know what, I'm just going to delete all the Android generated stuff and re-import my src files into a new project.

So I deleted them, but now I don't know how to import the src folder back into Android Studio! When I tried to import, Android does not create a gradle build for me. This is what I've tried:

  1. Closed AS
  2. Open AS
  3. Click Import project (Eclipse ADT, Gradle, etc.)
  4. Import project from external model -> Gradle -> Next
  5. Use Local Gradle Build -> C:/Program Files/Android/Android Studio/gradle/gradle-2.10
  6. Finish
  7. I get a notice "Frameworks detected: Android framework is detected in the project. Click Configure -> select AndroidManifest.xml -> OK

In Project Explorer -> Android window - no files are present. In Project Explorer -> Project window - files are present but has a red marking on them, I have no idea what they mean.

Example: enter image description here

The run, build, debug buttons etc are all greyed out. This tells me that the Gradle build wasn't successful.

Anyway, after I restarted AS, I now get this event log:

Migrate Project to Gradle? This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.

Why do I need to migrate? I told Android Studio to build gradle by pointing to the local gradle build?

What is the correct way to create a Android Studio project if you have source codes but not as an existing project in eclipse or android studio?


Solution

  • Maybe you should create a new project, then paste source files.