I'm trying to improve my android development skills, so working on some project about it. In my project, I added a new "Navigation Drawer Activity", then I deleted it because I wanted to create a new one but I can not able to add even another type of activitiy. Android studio adds ,
<activity
android:name=".ExampleActivity"
android:label="#string/title_activity_main" >
</activity>
tag in AndroidManifest.xml but It doesn't create any classes and xml layout files.
Also studio says:
ide internal error occurred android studio.
I tried regenerate R.java and clean my project ,but it doesn't work. How can I get rid of this problem?
Try to add a simple JavaClass and write an "extends Activity" behind the class name. And put this new Activity in the Manifest like in your example. You can add a menu and a layout like this, too, when you add xml-Files in the layout and menu folders. This should work.
I can not find a exact solution to that problem. Re-installed the Android Studio . It does the solution manually
If it's about how Activities is not showing up as an option in either the shortcut menu in the Layout folder or File + New in the menu, you can try File + "Sync Project with Gradle files" and give it some time.
This also adds options to the Tools menu (great if AVD or SDK Manager is missing).
Related
Scenario
I'm starting to learn Android Development on my Ubuntu laptop, but having issues with creating layouts with fragments.
Steps Taken
I created a new project with an Empty Activity
I right-clicked my app folder and performed: New > Fragment > Fragment (Blank),
Named it TestingFragment
Unchecked "Include fragment factory methods?"
Unchecked "Include interface callbacks?"
Under res > layout I updated the fragment (fragment_testing) to recognize it within the main activity
I went to the activity_main.xml file, added the FrameLayout to the layout
I tried to drag the < fragment > component to the FrameLayout
I receive an error message with just an OK button:
No Fragments Found
You must first create one or more Fragments in code.
My Best Guess
It appears that my Android studio is not recognizing that I have the fragment code created and just need to add it to the layout.
Perhaps I need to configure the Gradle scripts to be able to find the TestingFragment class?
What I've Tried from Googling Around
I have installed, uninstalled and re-installed Android Studio using Snapcraft
I have installed, uninstalled and re-installed Android Studio using android-studio-ide-191.5791312-linux.tar.gz from the official Android Download site within the /opt directory.
I have made sure all plugins are checked via File > Settings > Plugins
I have verified that my Android SDK Location is pointing to the right folder via Tools > SDK Manager.
Under SDK Platforms the following SDKs are installed and checked:
Android 10.0 (Q)
Android 7.1.1 (Nougat)
Android 7.0 (Nougat)
I have tried the File > Invalidate Caches / Restart... option choosing the Invalidate and Restart button
I have tried the File > Sync Project with Gradle Files option.
I have tried the File > Sync with File System option
Edit:
I have been able to go into the xml of the main_activity layout file and add a fragment tag manually and found that it can work. The following is the manual tag I managed to add:
<fragment
android:id="#+id/fragment"
android:name="android.example.testfragments.ListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragment_list" />
Still working on fixing the drag-drop "No fragments found" issue.
Where to go from here?
Does anyone know where I can go from here other than virtualizing another OS like Windows to see if it works there?
Solution
So after hours of poking around the settings and googling around, I discovered the reason why it wasn't working by accident.
While creating a new project, the application's Package name field cannot follow the "android.example.packageName" pattern.
After being unsuccessful for so long, I decided to try a new project and change all the options to completely start anew from scratch. During the process, I changed the package name to "com.frags.testing".
I then proceeded with the steps described above to make a fragment and I was successfully able to add the fragment using the drag-drop method into the main_activity layout.
I also verified that this worked by going back to my previous project where it wasn't working and creating a new package named fragments and refactored the fragment class to that new package. I then went back to the main_activity layout and dragged the < fragment > component to the layout and it successfully found the fragment.
Hope this helps someone else out there.
Cheers,
Justin
I updated from Android Studio 2.3 to 3.0 and now none of the previews on the XML editors are shown.
I can see a null in the top bar in the API level selector and it does not give me any option to pick
Any possible solution for that?
I tried Invalidate cache and restart but it does not seem to help.
Just press "Sync Project with gradle" and enjoy :)
Sync icon is present in the toolbar
I resolve this isuue by Syncing Project with gradle files.
In android studio from top toolbar.
choose first File option and click option Sync Project with gradle files.
thanks.
choose first File option and click option Sync Project with gradle files. work for me
In my project I have got a lot of drawable content, and when I need to add new images to drawable I can put a same resource because I forget I have it already.
It is not about preview on XML file, this works well.
Any features in Android Studio to preview all my drawable contents without double-click on every resource? It can save lots of time.
I didn't find anything at Preferences, maybe some plugin or did I miss something?
Starting from Android Studio 3.4, you can use Resource Manager, a new tool window for importing, creating, managing, and applying resources to your app's layouts. You can open the tool window by selecting
View > Tool Windows > Resource Manager from the menu bar.
Right click on drawable folder and click 'Show Image Thumbnails'.
I'm using Android Drawable Viewer that can be installed from Plugins in AndroidStudio. After installing and restarting Android Studio, you will find a tab on the right side of the editor where you can find the viewer.
Click on that tab and you'll be asked to select the root folder for drawables. Do it, and after, everything will look like this:
Consider using Android Drawable Preview plugin. It shows content of the images instead of default icons when you expand drawables.
It even renders vector xml drawables!
Like this:
To install it: go to File > Settings > Plugins > search for Android Drawable Preview and click to find in repos. Install it and restart Android Studio.
Cheers!
Note/ when using 'Show Image Thumbnails' (as #Akhil Tawari suggested) in "Android" view as opposed to "Project" view, for image thumbnails of all drawables right click the "res" folder and not the drawables folder/s.
You can right click on the folder and click open in files. This will allow you to open up the project folder in which you can more easily add and delete images and other files.
i have some old projects in my android studio ide.
I never need them.
When I right click on a project I can't find an option for deletion, is it elsewhere?
how i can delete a project in android studio 0.3.4 ?
Open the .idea/modules.xml, and delete you module, then right click on you module, you can see Delete....
You have to mark the project folder as excluded, once you've done this, you'll see the 'delete' option.
This method is explained with more detail in this link, which seems to be the same you're looking for
How to delete a module in Android Studio
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.