Using phonegap and Android Studio 0.8.2 - android

There are only 3-4 articles on how to use Android Studio with Phonegap.
The problem is that these are all written for lower versions from Android Studio (<0.8) and now you can't import Phonegap projects into Android Studio without having multiple errors.
Has anyone achieved it to import a Phonegap 3.5 project into Android Studio 0.8+ and will share his/her knowledge?
Edit:
Ok if you don't have errors then you can describe the way you do it!
My steps:
phonegap create projectname id projectname
change directory into projectname
phonegap build android
-- so far no problems
start Android Studio
"import project"
choose projectname folder
apply the rest steps with next and finish the import
Android Studio now has imported my project
try to test the new project by go to "Run -> Run..."
add a new "Android Application"
BUT THEN in the tab "General" you have to specify a "Module" otherwise you can't start the application
Ok and from here on I stuck.
I tried to do "Build -> Make Project" but this ends with multiple errors while Android Studio tries to compile the app.

I think the Gradle has conflicted with ant because they will generate same files. I delete the ant-build files then it works. Hope it be useful.

Related

Android Studio 3.5 can't open previous version projects

I have a project stored in GitHub, it was created a few days ago using Android Studio 3.3.
I have installed Android Studio 3.5 on a new Windows, and checked out the project to the disk.
When I open the project in Android Studio 3.5, in Android view I only get an empty app item.
The Project view shows all the files yet it seems the project itself isn't loaded.
What should I do to load the week-old project in this very best IDE of great improvements?
Open Android Studio Launcher; or use File -> New -> Import Project
Select "Import Project"
Select project folder
Follow next steps *you understand another
When I have same problem, I use this steps to solve it.

Automatically Migrating projects to gradle in Android studio

I made some apps in the past with android studio, and there was no problems with them.
And I could open example projects from many sites, for example: developer.android.com/.
Now after an update of android studio, I can't open projects in android studio without migrating them manually, which was done before the update by android studio itself.
What could be the problem now?
First I get this warning, that android framework is detected.
Then after choosing the setup frameworks and clicking ok, I get this:
As you can see it is not gradle based project.
What can I do to make android studio automatically migrate projects again?
IMPORTING ANDROID STUDIO PROJECT IN ANDROID STUDIO:
If you want to import An Android Studio Project then do the following:
1.
Select Open an existing Android Studio Project
2. Browse your desired project derectory.
3. Now rather than selecting the folder that contains your project, you have to select the build.gradle file that is just inside of your parent folder of the project.
It will not create any problem and will not ask you to migrate into gradle and import any framework at all.
IMPORTING ECLIPSE PROJECT IN ANDROID STUDIO:
If you want to import Eclipse Project in Android Studio:
1. Select Import project (Eclipse ADT, Gradle, etc.)
2. Then nothing special just follow the instructions in the wizard.

Importing and converting Eclipse-made Android project from Github to Android Studio Gradle-build

I'm trying to migrate from using Eclipse for my Android-project to the new Android Studio, and I'm having an issue related to Gradle.
What I want is for me to push the latest Eclipse-build to Github, and then be able to pull it down in Android Studio, having the latter automatically convert the project to a Gradle-build. If I'm reading the documentation right, the Android Studio import is supposedly able to do this.
When importing, I can choose between "Create project from exisiting sources" or "Import project from external model"
If I choose the first option, the project won't use Gradle (as far as I can see). If I choose the second, it seems to be looking for an already existing gradle buildfile "build.gradle" in my project.
So - Should I download a Gradle-plugin to Eclipse and make a gradle build-file there, or am I doing something wrong in the import?
It seems the only other questions I can find on SO is about importing and Eclipse export or simply how to pull a project from Github in Android Studio.
Thanks :-)
Importing and converting an existing Eclipse project into a Android Studio Gradle project is quite simple :
File -> Import Project (in Android Studio)
Select the manifest of your Eclipse Android project.
Done.
There may be some dependacy management to deal with.
You can also take a look here :
How do you import an Eclipse project into Android Studio now?
How about this:
clone repo to location 1
export from eclipse
import to android studio in location 2
copy the .hg files or whatever's applicable from 1 to 2
commit from location 2 including deleting eclipse files
Now the repo will have the android studio project and not eclipse.

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.

Convert a project to Android Studio

I'm trying to open the following project https://github.com/mik3y/usb-serial-for-android on Android Studio but all the things I try it give me errors related to gradle :s
It says version 0.9.0 introduce some incompatible changes but then I can't make the changes they said.
Can anyone try it to me?
The biggest issue is that Android Studio uses Gradle and Eclipse does not. It sounds like the GitHub project was built with Eclipse, which means you first have to import that project into Eclipse, then export it with the Gradle files.
From the Android docs
Export from Eclipse
Update your Eclipse ADT Plugin (you must have version 22.0 or higher).
In Eclipse, select File > Export.
In the window that appears, open Android and select Generate Gradle build files.
Select the project you want to export for Android Studio and click Finish.
Your selected project remains in the same location but now contains a build.gradle file and is ready for Android Studio.
Import into Android Studio In Android Studio, close any projects currently open. You should see the Welcome to Android Studio window.
Click Import 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.) Now that your project is imported to
Android Studio, read Tips and Tricks for some help getting started.
Note: It's possible to import an existing Android project to Android
Studio even if you don't generate a Gradle build file from
Eclipse—Android Studio will successfully build and run projects using
an existing Ant build file. However, in order to take advantage of
build variants and other advanced features in the future, we strongly
suggest that you generate a Gradle build file using the ADT plugin or
write your own Gradle build file for use with Android Studio. For more
information about the Gradle build system, see the Gradle Plugin User
Guide.

Categories

Resources