Java class file not generated for new activity in Android Studio - android-activity

I'm just starting out with Android development and in general I keep hitting brick walls that seem to have more to do with the IDEs then the anything else. I started out with Eclipse but it kept corrupting my projects and other weird errors. Now I'm trying Android Studio which seems more stable but again a brick wall:
After following the android tutorial to the letter to create the hello world app I tried to add a new activity. The xml file was created fine but the java class file did not show up under src like it did in eclipse. What gives? This is demoralizing me. I long for the days of writing C code for microcontrollers using just an editor and cmd line.
Thanks.

Goto File -> Settings -> Compiler
check use external build then
rebuild project

Update your Eclipse ADT plugin, then export project and the import in Android Studio.
And follow the below link
http://developer.android.com/sdk/installing/migrate.html

Related

Why unityengine.ui is not recognized?

I have a problem were i try to create a score system in my game where the player is getting points based on the distance he travelled, and the vs code is not recognising the "Using UnityEngine.ui;" I already tried to switch vs code to a lower version (I went to 1.1.3) but it didn't work. Here is my code:
You Could try a could try a couple of solutions -
Solution 1) Relaunch the unity Engine and VS code and check.
Solution 2) Go to Edit > Preferences > External Tools make sure Edit > Preferences > External Tools make sure the
'Generate all .csproj files'
is checked the in your IDE delete the:
Assembly-CSharp-Editor.csproj
Assembly-CSharp.csproj
Ecology.sln
files in the root of your project.
Close and reopen vscode.
Solution 3) Uninstall Unity Hub and reinstall again and try.
Solution 4) UnityEngine.UIElements; instead of unityEngine.UI;
UnityEngine.UI namespace is a part of the aditional package called Unity UI, and it seems you don't have it imported in the project.
Click on Window on the top-left menu in Unity Editor -> Select Package Manager -> Search for Unity UI -> click Install.
Well it seems that I already had ui tool installed so I tried to unistall the package and reinstall it. Vs code still throws an error sometimes but after I close it and open it again it works just fine. Thank you all for your help.
There seem to be a problem with the VScode package version 1.2.4, where regenerating csproj files from the preferences doesn't make Unity UI symbols available in vscode.
Going Back to version 1.2.3 solved the issue for me (from latest Unity 2020.3 LTS release).
These steps covered several possible issues:
https://stackoverflow.com/a/70977258/6046022
(just an overview, follow the link for the complete steps)
downgrade VSC package
re-install Unity UI
regenerate files
I have the same error what take me a lot of time to fix. And finally I found my reason that I meet a problem with duplicated extension in the same project. My one is "External Dependency Manager" what somehow installed already on Unity Package Manager, after I delete old Admob plugin and install new one what make install new "External Dependency Manager" without override or delete old one. That make Unity not work well.
So check and try to delete/uninstall "External Dependency Manager" in Unity Package Manager first then import new one will be fine. At least in my case
Hope this help

How can I fix "build failed, do you want to continue"? In Visual Studio Code

I got an error when trying to debug Java code in Visual Studio Code.
The error is below
build failed, do you want to continue?
I have tried clearing the workspace, but it doesn't work. How can I fix this issue?
The problem was solved.
I resolved this issue by clearing the workspace cache in Visual Studio Code. Here is a link to the relevant page: Visual Studio Code Clean Workspace Directory. I had renamed a number of folders, class names and packages.
Apparently the Red Hat Developer plugin managed to get out of sync. The .classpath file was out of sync with the POM file. Wiping out the workspace cache caused the plugin to recreate project data from the Maven specification. The problem was solved. I am not sure, but if anyone from the Red Hat project reads this, it looks to me like a bug, or deficiency. In any event it can be worked around.
Original answer:
I think Liu Bei was not clear enough. I am experiencing the same issue. I have a project that builds perfectly in Maven and when I launch the debugger in Visual Studio Code this notification appears in the lower right-hand corner of the Visual Studio Code window.
Obviously the "Debugger for Java" extension thinks there is a build problem. However there are no errors reported in the PROBLEMS, OUTPUT, DEBUG CONSOLE or TERMINAL tabs.
The project builds, and packages in Maven just fine and it can be debugged in attach mode which is tedious at best.
There is something going on in Visual Studio Code that's not being reported anywhere that I can find. I suspect the RedHat Visual Studio Code plugin for Java is in the mix, but I need help figuring out how to work around the issue.
I have to say that we are spending way too much time resolving issues with tools and dependencies and not enough time on the app. The project we are working on is intended for open source distribution. The Spring Framework seems ideal for our purposes, but the tooling, not so much. We are not very far into the project and I am already receiving pressure to switch to ASP.NET Core.
I really need a little help...
This didn't work for me, but I found out what did.
First of all, looking at the Java Dependencies plugin gave me a hint that something was out of sync. The name of my application (artifact) did not match the name in the Java Dependencies tree view.
This was fixed by clearing the Visual Studio Code workspaceStorage folder completely!
This folder was in my case located in (Windows 10):
C:\Users\<myuser>\AppData\Roaming\Code\User\workspaceStorage
If you can't find it at this location, simply search for the folder workspaceStorage.
Next press Ctrl + Shift + P (in my case) to open the Visual Studio Code action prompt. Then choose the command:
Java: Open Java Language Server Log File
This will open a log file which is normally not displayed when building your Java code, and will tell you exactly what went wrong with the build.
In my case it was a conflict as I had two AppConfig.java files, one in main and one in test. Maven handles this fine, but apparently the Visual Studio Code Java builder does not.
Obviously these are bugs in the plugins which I will report to the GitHub contributors, but for now we will have to live with a little manual work.
Still I hope this helps all of you frustrated Visual Studio Code Java developers out there.
It worked for me to change the user setting in file setting.json to "java.debug.settings.forceBuildBeforeLaunch": false in Visual Studio Code, which will disable the check before run/debug.
Build failed error in Visual Studio Code
This error occurs because in your workspace folder the other source code has some errors in it.
So create a new folder and make it as a workspace folder and then write your codes in that folder and run it.
I had that error also and it worked for me, so check for yours.
Using OS X, I managed to overcome this problem. You can either access it from your Terminal or simply use a
shortcut (Command + Shift + C).
Select Base System and Library. Look for the Java folder and click on the Java Virtual Machines folder.
Check if is there the actual version of JDK (most up to date). I've noticed that I had two JDK folders one probably inherited from a previously installation and the most up-to-date Java 15. I dragged 'jdk-14' to the waste bin. Enter password, close finder and restart Visual Studio Code.
It works fine now!
For me, the problem was that I created a folder within a folder for arranging my Java program files with the reference to data structures. In the log file, it was showing that the .java file in the inner folder was not on its project's build path.
Just after deleting that folder and completely deleting all the files in the workspace folder manually in the location C:\Users<myuser>\AppData\Roaming\Code\User\workspaceStorage, this problem was solved!
I fixed this problem by doing the following steps:
Step 1: Opening Visual Studio Code settings (bottom left) https://i.stack.imgur.com/xPlkj.png
Step 2: Searching "Java debug" and selecting Java Debugger under Extensions https://i.stack.imgur.com/797M3.png
Step 3: Find Force Build Before Launch and uncheck it https://i.stack.imgur.com/igtRa.png
And you're done!
First of all, check carefully the errors on Visual Studio Code log and try to not get biased by the community common errors. To do this, press Ctrl + Shift + P to open the Visual Studio Code action prompt. Then choose the command:
Java: Open Java Language Server Log File
By doing this you can find the exact exception that is happening. In my case, I had two exceptions:
java.lang.NoClassDefFoundError: javax/annotation/processing/AbstractProcessor
And
java.lang.NoClassDefFoundError: com.demo.myapplication
So, I was biased to think that error was related to the Java version or stuff like that, but it was related to a Lombok extension installed in Visual Studio Code.
In the end, I found this thread and tested this solution and it worked like a charm.
Here is the solution explained by him:
Finally I got it working. The issue is with the additional argument -Xbootclasspath added by the Lombok extension to the java.jdt.ls.vmargs. I figured it out by integrating the Lombok with eclipse and opened the eclipse.ini file for the changes.
I uninstalled the vscode-lombok extension;
I downloaded the lombok.jar (version 1.18.6) file from https://projectlombok.org/download;
In Visual Studio Code, in settings.json, for java.jdt.ls.vmargs key, I added the argument
-javaagent:"PATH_TO_DOWNLOADED_LOMBOK_JAR_FILE"
A last necessary step (missed by the GitHub guy) is to reinstall the Lombok extension.
I had the same problem.
I just downloaded this provided for Visual Studio Code,
Extension Pack for Java.
Click on the link, download and open it. It will automatically configure Visual Studio Code for Java.

Eclipse does not seem to recognize Native Android code

I am trying to learn about native Android, using NDK.
I find some sample projects in NDK folder and on the Internet. After much configuration, they are runnable.
But, my problem is: when I open a .c or .h file in JNI folder with Eclipse (just want to see what it is), Eclipse shows many error in this file. For example, it don't know what is JNIEnv, jobject, jstring.
I haven't made any change in the project, just opening it. Errors mean I can't rerun it again except if I delete it from the workspace then reimport it.
Eclipse does not work well with C/C++ files. At least, for me it did not.
After some search, I have managed to configure Code::Blocks to support NDK, please see this answer to the question:
Need a simple Linux C++ IDE (Android NDK) .

How to convert cocos2d-x android project to c++ in eclipse ADT

Hi I'm fairly new with Eclipse. I'm trying to work on my cocos2d-x project on Eclipse, but for some reason I couldn't convert the android project to a c/c++ project and so I couldn't open the c++ files inside the Classes folders as you can see on the image here.
cocos2d-x: cocos2d-x v3.0 alpha0
eclipse: (ADT)Android Developer Tools - Build: v22.2.1-833290
os: windows 7
What I did:
ran create-multi-platform-projects.py in cmd
opened eclipse(ADT) then File->New->Other->Android Project from Existing Code->browsed to {cocos2d-x v3}/projects/mygame/proj.android
built the project.
tried to convert the project. Right-clicked project->New->Other->Under C/C++ tree, select Convert to a C/C++ project (Adds C/C++ nature)
but then the candidates for conversion is empty, meaning I couldn't convert my project to c++. I have installed the C++ plugins as seen here. Obviously I'm missing something here but I can't figure out what. I've been following tutorials on setting up cocos2d-x android development on eclipse windows os but I'm stuck with the converting to c++ step. Please could someone point out what I'm missing. Thanks in advance.
It will already be having c++ nature, so it wont show you that option (You can verify this by checking if you have C/C++ build in your project properties)...
You can open the cpp files by adding a reference to the source folder, to do so follow the below steps:
Right Click your project and select properties
Goto Resource->Linked Resources
In Path Variables Tab, Click New...
Give some name and choose the folder where you have your source code
It will now show a link to the source code folder in the project
Here are one by one steps, You may setup easily!

Edit and Compile AOSP Core/System Apps in Eclipse

I've been banging my head off my keyboard all day trying to figure out how to import one of the core/system apps in the AOSP into Eclipse to edit/debug it (in this specific case, the Settings app in Android 4.0.4).
I've followed numerous guides on the subject, including this one here which got me VERY close, but the code is still returning 167 errors.
Anyone have any experience or insight with this problem?
Thanks!
This is how I have done it. Use eclipse to edit/browse/debug platform code using an eclipse project. To build the platform, I use terminal and build the whole image or build specific folder (i.e. Using mm helper).
To create eclipse project for AOSP sources, please check Using Eclipse to edit/browse AOSP.