Android Studio kotlin file name is not recognized - android-studio

The file structure and class name
So I have this file structure (checkout the link), as you can see, the Doctor is recognized normally, there is only one open class in the Doctor.kt class which is the Doctor class, and the HospitalDoctor.kt file also only contains HospitalDoctor class that extends Doctor, but it is recognized as a plain text file by the android studio, if I change it to any other name such as "my class", "newclass", and even "HospitalDocto" (miss a r at the end) it will be recognized as a class file as it should be. As AS think this file is txt, it shows error when I create a HospitalDoctor instance(unresolved reference), but it can actually run normally without any error. And the same project if I open with any other IDE like Intellij, it doesn't have this weird issue. What's going on with my Android Studio and how to fix this?

Related

Why does Android Studio enter the full path for some classes?

I have the following code for creating a custom adapter and android studio is defaulting to the full path of my package. This was not always like this. I wonder what has changed. And it doesn't know what localNetView is even though is declare at the top of my class. Why does Android Studio do it like this? Without making any changes can't find the classes.
private ListView localNetListView;
private Adapter localNetAdapter;
localNetListView = (ListView) findViewById(R.id.local_network);
localNetAdapter = new org.pctechtips.netdroid.HostAdapter(this, R.layout.list_main, localIfaceInfo);
localNetListView.setAdapter(localNetAdapter);
Make sure the "Use fully qualified class names" option under File > Settings > Editor > Code Style > Java > Imports tab is unchecked.
If this is only happening to a file, check the imports manually and see if another class with the same name (and different package) is imported, and remove its import line.

Android Studio Method doc for jar file

I created a jar file using android studio exposing some methods and using the jar file in another android project.
For accessing any method when I type the first letter of method, the Android Studio intelliSense shows me different option of method names along with the parameters expected by these methods.
The parameters names that appear are (String s1, String s2) and so on instead of original parameters like (String Name, String Address) which does not gives a proper meaning.
What can I do to change this behavior?

From Eclipse to Android Studio: Why is proguard.cfg used when NOT building Release?

So, I have been trying to migrate the development of a multi-project (eclipse projects that is) app to Android Studio (v1.1).
Importing via File > Import Project was really easy and went without incident.
However, when I tried Make/Rebuild project I encountered numerous surprises. The first, not Proguard-related, had to do with source file encoding (originally in Windows-1252), but I quickly found a solution using this Windows-1252 > Reload > UTF-8 > Convert answer.
Then, "error: cannot find symbol class" for a com.comp.mod.X class of mine. I then solved it by going to the module (Android Studio module that is, previously an Eclipse project) that contains that class and added to its proguard.cfg the following:
-keep public class com.comp.mod.X
Which left me with an "error: cannot find symbol variable" for a const BB defined in the aforementioned class. I solved this by adding to the same proguard.cfg the following:
-keepclassmembers class com.comp.mod.X {
public static final boolean BB;
}
That left me with only one "error: cannot find symbol method getPreferenceX()". I solve this by adding to the same -keepclassmembers that method, so that the above now looks:
-keepclassmembers class com.comp.mod.X {
public static final boolean BB;
public static java.lang.String getPreferenceX();
}
I thought I was done, but to my dismay, when I attempted to rebuild the project, I received numerous additional errors from other modules in the project, all of the type to "error: cannot find symbol class/variable/method" and related to some proguard.cfg.
I could have continued butchering the proguard.cfg files for each and every module but at this point I am beginning to suspect that I am doing something fundamentally wrong, because those proguard.cfg files work perfectly under Eclipse. So,
Why all of a sudden these are no longer good for Android Studio?
If ProGuard runs only when you build your application in release mode, why is the Android Studio based build complaining about "cannot find symbol" due to Proguard's obfuscation?
What am I missing?
Note: I have not attempted "Generate Signed APK". All I do is "Rebuild Project".
Currently (as of 2015-04-24), minifyEnabled's default value of false for all build types is incorrect for multi-module projects, in which some modules (app included) are dependent on other modules. This is due to bug #52962 that causes build types to not propagate to libraries -- they are always built as RELEASE.
Suggestions to work around this bug or notifications of its fix are most welcome.

Typescript giving "Output Generation Failed" in Visual Studio 2012 with 0.9.5

I've been using Typescript 0.9.5 for the last few days, and then suddenly today the JavaScript files just stopped being generated. I see an error "Output generation failed" in the Visual Studio status bar, but nothing in any of the output windows.
I've rebooted, and restarted Visual Studio, disabled Web Essentials, tried all the usual things.
The files are set as TypescriptCompile in the properties. I've tried adding new files, or editing old ones with no effect. The Project file hasn't been changed as far as I can tell (its in TFS and none of the TypeScript sections have been altered).
I've made sure both files are checked out, still nothing.
Update: I've managed to compile manually using tsc.exe from the command line, so it must be something in Visual Studio.
OK, so I solved the problem.
One of my files contained invalid typescript, specifically trying to export a class when not inside a module. This caused all typescript files to fail to generate, but with no useful error message.
The following file would cause the problem:
export class Test {
public DoSomething() {
}
}
Either removing the export keyword, or adding a wrapping module solved the problem.
I've raised it as an issue here: https://typescript.codeplex.com/workitem/2109
Update: More details.
The above syntax is valid if you are using the CommonJS or AMD module patterns.
To enable this in visual studio you need to edit the .csproj file and insert a new PropertyGroup:
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
If you have an export outside of an internal module Typescript tries to compile it as either commonjs or amd module format. The compilation will fail if the a --module flag is not present on the command line. Use your project properties to set it to the desired value (probably amd in your case).
More info on TypeScript modules : http://www.youtube.com/watch?v=KDrWLMUY0R0&hd=1

The hierarchy of the type MainActivity is inconsistent

I created a new Android project via eclipse, with a MainActivity.
I added ActionBarSherlock to the project (Properties > Android and clicked Add).
Then, when I replace "extends Activity" with "extends SherlockFragmentActivity" I get a compile error "The hierarchy of the type MainActivity is inconsistent".
I also tried to create a project without an Activity, then created a class "MainActivity" that inherits from SherlockFragmentActivity, and there are no compile time errors, but with a run-time error "ClassNotfoundException: com.NadavLitvak.nadavfragmentdemo.MainActivity"
Your project should also reference the android-support-v4.jar (which is included in ABS's libs folder.) So, Properties->Java Build Path->Add JARs... and select that jar from ActionBarSherlock->libs
Sometimes, when Eclipse gets retarded, it doesnt add the SDK jar in your project (the Android x.y folder missing in project) so then you need to add it Properties > Android > Project Build Target (usually nothing there is ticked)

Resources