I am just starting to use Android Studio.
I have followed the steps through in the Studio. I chose "Basic Activity". The app loads, but there's nothing but empty directories there and it has no activity folder or anything to edit the layout with.
I checked it in the Windows explorer, and it just looks the same as in Android studio.
I've read this, this, this, this, this, this, and other ones, and have probably spent over an hour trying to figure out how to do this.
I've also re-tried creating the project at least 5 times, but I've had no success.
Edit: Here's what the app folder looks like:
Edit: Someone told me I should just create a new activity. Being an absolute new person, I didn't know how to do that, so I looked at this post. However, the post tells me that I need to go into the "New" menu, but I don't see "Activity" in here like the post asserted it would be.
In the following menu click the arrow and select "Project" (is better):
Then go to "name of your project folder" > "app" > "src" > "main" > "res".
I have no idea if this was what was causing it, but first I uninstalled then re-installed Android studio, deleted the old project, and created a new one.
It still didn't work, BUT I just noticed a little error log button.
You see, I named my application com.con.pfq. It wasn't liking the "con" part - said it's an invalid file name.
Sooo... I recreated the app as com.connoriscool.pfqmmobile. It liked that more.
No idea what's happening here, but that's the solution.
Related
I think the people who write the tutorials forget that the people reading them are new to the topic. We're supposed to learn about those by stepping through things, but if something goes wrong we don't know where to look for the error.
I have Windows 7 Pro, I have not attempted any eclipse development for android on this machine (though I use eclipse for other things). I downloaded the Android tutorial just now, installed it with defaults (I doubled the memory size from 2G to 4G on whatever component that was) and told it to start up after it had installed. "Help / About" says it's "Android Studio 1.3.1".
I followed the tutorial instructions for creating a new project, changing the names of the couple of files where it indicated. When I attempt to run it, the log file at the bottom of the AS window says:
Error retrieving parent for item: No resource found that matches the
given name 'android:TextAppearance.Material.Widge.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that
matches the given name 'android:Widget.Material.Button.Colored'.
On poking around, I seed that the "MyActivity.java" file is underlined in red, and there are three references in it to "R", also red. If I hover over any one, it says it cannot resolve that symbol.
I also found a file named "v23\values-v23.xml" that has red text for what look like a couple of android components; one of them is the following:
<style name="Base.Widget.AppCompat.Button.Colored" parent="android:Widget.Material.Button.Colored"/>
and the value for 'parent' is underlined in red. Since this looks like it indicates an error with something called "parent" and my runtime error message says "parent", it seems logical they're related.
But I don't know where to go from there. I vaguely remember an instruction to download an Android SDK, but thought that was included with Android Studio (can't imagine why it wouldn't be). It was called the "Android Studio SDK Bundle", I figured that included what was needed.
Other SO questions on the subject are evidently too old, saying to click on menu options that no longer exist, etc., or say things like "open the gradle file" and I can't find one, or "be sure your target project version is set to 11", and I don't have any idea what that is or where to find it.
Please be explicit about menus to use and options to click on; remember that, though I'm an experienced Java programmer, I've not used IntelliJ and I've not programmed on Android, so I don't know the names of things specific to either environment.
Daniel Nugent called this shot: at the bottom of the left-hand pane is an option called "Gradle Scripts". My first one was named build.gradle (Project: MyFirstApp), and my second build.gradle (Module: app). Double-clicked on the second one and changed "compileSdkVersion 22" to "compileSdkVersion 23", then attempted a rebuild which failed. The question Daniel Nugent referred to also mentions ensuring I have "Android M libraries" and points to a button on the Toolbar to start the SDK manager; that showed that an update "was available" for Android 5.1 (Lollipop). I couldn't figure out how to update from that window; I guessed at clicking on a link in that window (at the bottom) saying "Launch Standalone SDK Manager", and updated from there (which took a LONG time - 15-20 minutes).
Then the rebuild on Gradle succeeded and running the application (which took perhaps a minute or a minute and a half, longer than I expected) produced the expected window to pick a device, etc. The emulator then ran the "Hello, World" app as desired.
My thanks to all who responded; now if I can just figure out what's wrong with the debug driver for my Galaxy s5...
I start my first Eclipse Project but I cannot create any Activity, I already Restart my IDE and Even restarting my Computer does not help.
What I did when creating a Project:
File - > New Android Project - > Fill-up Information (min:API-8,Target and Build:Android 4.XL prev) next ---> next ---> Blank Activity ---> Fill-up Again -- > Finish
But no activity is in the SRC folder, I need to know whats wrong with my IDE or related to my problem.
I also done Updating using this CDN http://dl-ssl.google.com/android/eclipse/ but it wont work.
I got the same issue as you do and I have a working solution which is I already posted here
Eclipse doesn't create Main Activity and layout
Using this Eclipse Update http://dl-ssl.google.com/android/eclipse/ did not work for me. I notice this problem when I download the latest updated SDK
Luckily the solution to my problem is very easy.
By Selecting Empty Project instead of Blank Activity makes it working.
I update my os to win 8.1.Then i installed adt bundle.When i create a project on eclipse it creates project without any activity.I mean the src file is empty and also there is no xml file like main_activity.xml.Btw i can debug my old applications that i developed on win7.
Then i update my sdk.This time it creates activities but as an actionBarActivity.I mean MainActivity extedns ActionBarActivity.Also when the project created on folder appcompatv_7 is automatically created on my workspace.Then i code something it doesnt work on my phone but i know the code is totaly true.Help me please.
I removed the adt and reinstall it.
I check the updates.Eclipse didnt found any update.
My sdk manage looks like
You can always make your own activity by going into: src > com.example.projectName. Right click this, and create a new class. Make that class extend Activity.
If you want Eclipse to make your main_activity for you, then you probably did not "check" one of the checkboxes to make a new activity along with your new android application project. To do this, please do the following:
1. File > new > android project
2. A new window should appear. Name your android application as usual, and click next.
3. This step is important. You must check the "Create Activity" checkbox. You probably did not do this the first time, which was why
you had an empty android application project.
4. Click next until you see the "Create Activity" option. You can choose from either a blank activity, Fullscreen activity, or
Master/detail flow. Click the "blank activity" in order to get a
normal activity (and when I say normal activity, I mean the
MainActivity.java and the main_activity.xml)
Also, whenever you make a new activity in a pre-existing project, be sure to carefully read all the options. Right click your package in the src folder, press new > android activity, and carefully read all the options.
I hope this helps you.
I have re-started Eclipse, re-run the application numerous times, and saved all of my files in my application. In my .xml, I have gotten rid of a button.
The .xml is inflated in my .java file. However, when I run my application on the Android emulator, it keeps showing the button that I deleted.
reinstall the application, clean the project in eclipse.
One possibility is your emulator is not connected to the ADB (Android Debug Bridge)
To check just do:
cd C:\Program Files (x86)\Android\android-sdk\platform-tools
adb devices
You should see
List of devices attached
emulator-5554 device
If you don't see this, manually kill the adb.exe process (DON'T kill your emulator).
Then manually run adb.exe again.
When you do adb devices you should now see your emulator. If you close/kill your emulator you may have to repeat the process again.
I would have thought that restarting Eclipse would have had the same effect anyway, but for what it's worth, always try Project -> Clean in situations like this.
Clean the project and then run.
OK - I tried all this and it did not work (but I did resolve the problem...).
My project is very simple, as I am a complete newbie and had only created a mock up of the app - a simple interface and adjusted the strings XML file. None the less, I wasted a couple of hours trying to fix this damn problem. In the end, I simply generated a new project and ported all my work over. This took 10 mins and worked perfectly.
To try to learn why this happened, I repreated the steps that seemed to have caused the problem (clearing all projects, and then building them all again) - having copied all the code fromt he original project (including the manifest). I could not break it again, so am none the wiser about what caused it.
A more complicated project might be more of a challenge, but I thought I would post in any case, as I wasted a lot of time trying all these other things without sucess.
Uninstall the application from Setting->Application->Manage Application->Select Your app->Uninstall. and then run.It will work
To detail Rasel's answer (in addition to Project...Clean) you can also go to a shell and type adb uninstall com.example.applicationname.
The problem happened to me when I imported the project using the orginal files in Eclipse. It worked after I imported the projekt into the eclipse workspace as a copy
I had the same problem in Android Studio. When I added an imageButton it was visible in preview tab of Android Studio, but not in the emulator. I tried almost every solution mentioned in Stack Overflow for similar situation, but I didn't succeed. One of answers said that you should create a new project and copy your files into it, but this solution had a huge cost for me and I didn't want to try it. Finally I renamed my layout file in the onCreateView method:
View view = inflater.inflate(R.layout.fragment_story_edition, container, false);
Then I created a new layout resource and left it empty and ran the project in order to get an error. After that error, I copied the content of my original layout file to my new made layout file, and the problem was solved.
I am trying to refactor my package using Eclipse
org.sheehan.activity
to
org.sheehan.stocks.activity
For some reason my project just blows up when I do this and R doesn't get regenerated. How can I refactor properly?
UPDATE:
I updated my Android Manifest to reflect the change. R still doesn't get regenerated. Even after a clean. The compiler is complaining about org.sheehan.activity.R
I resolved by:
Android Tools > Rename Package Application
If you renamed properly, all your references across your project should have gotten updated. After doing this, clean your project by going to Project > Clean. This should fix it.
Fixing missing reference to R in eclipse:
Refactor -> Rename`
Build -> Clean
Android Tools -> Fix Project Properties
select the base package of your project in the eclipse package explorer, press F2 (Rename), in the rename dialog: SELECT ALL the checkboxes.:
That should do it
The package name doesn't update in the XML files. Specifically your manifest which needs to know the base package.
For more advanced imports and refactors, literally closing the Eclipse IDE can refresh a cache that causes random errors like "End position lies outside document range" or the "what once worked now doesn't hair puller outter errors."
Signs you should close Eclipse when trying to rename things are:
When you import a project, do some refactoring (like trying to change the package name), then delete the project and try again, you will see immediate R.java errors when you didn't before
When you are importing projects that have manually generated R.java files that have custom imports like "com.ns.proj.R" and don't see the name update in Preview
The box that asks if you want to "Rename subpackages" is checked unexpectedly
the code in the "Preview>>" looks as if it's been complied before instead of black and white code with the proper names replaced
you get XML errors in the manifest activity name like this
android:name="com.ns.proj.CustomCocom.ns.proj.CustomControlse="#android:style/Theme.Light.NoTitleBar"
when it should be
android:name="com.ns.proj.CustomControls"
android:style="Theme.Light.NoTitleBar"
There are too many to name obviously, however this is as important as "keep your eye on the ball" in sports. Something that is so easy to forget, yet things like these apply to other software programs like Dreamweaver (e.g. when you use the Dreamweaver "Put" option instead of FTP dragging with FileZilla and you notice your domain isn't updating your changes online). I called Adobe when I first started as a developer 8 years ago because I knew I wasn't doing anything wrong. They said sometimes the generated files to perform the action get corrupted...in other words, IDE's have bugs too!
In general, close the IDE before you off yourself...it could save your life!
Right click in your Project, go to
Android Tools > Rename Package Application
Sometimes if Project > Clean doesn´t work, so Delete /gen and /bin folders of your project.