Unresolved reference: FlutterActivity - flutter

I was researching a bit about writing native code in flutter. On opening the MainActivity.kt file in android I faced these issues.
On highlighting the error it showed 'Unresolved reference: FlutterActivity'.
Can someone please help me to fix this issue ?
Thankyou in advance.

I got the solution for this.
If you want to write native code or edit existing native code you have to open the "android" part of your project specifically.
You can do that be going to : File -> Open .....
Then browse to your current project and select its "android" folder and open it :
Then click "OK".
It will open the android native part of your project. All the errors will be gone if you will open the MainActivity through this path.

just open it in android project view in a new window then finish it until it build. then if you get any error debug it there. but if it is built successfully and shows an error in flutter project view leave it it is just the editor bug.
[1]: https://i.stack.imgur.com/BGkrc.png

In my case it helped to import the android folder of the Flutter project as a Gradle project. Once Gradle finished building and indexing, the error went away.

Related

Problem Import Flutter Project to Android Studio

I tried to import flutter project from my pc to the android studio and got this error.
I already read the link that they give to me but I still don't understand. A little help please, or how do I import flutter project correctly?
The error
The project is not Gradle based can be because bulid.gradle and settings.gradle are not in the IDE project directory,
Try this
Open that other folder as an Android Studio Project and let it download other dependencies and file or you can create new flutter project and check the file generated with yours and try to add the file not in your own from the new flutter project you created.
This will solve the issue
from which version/tool you imported the project?. This is normally happed because of gradle-wrapper issues. Please check the link.
https://quick-adviser.com/how-can-we-solve-project-is-not-a-gradle-based-project/
I usually solve this by File -> Repair IDE

Android Studio error when opening existing project

I am currently trying to run an existing project in Android Studio ,but when I loaded the project in my android studio ,it gives me error, which is target url does not exist error. How should I fix this problem ,because i just cloned the whole project using the url.
enter image description here
Since i cloned the project,the packages should all be there,but it gives me error for most of the import package lines.
I am not sure if the get dependencies can solve ,but i did not find it or there is another method can solve this problem.
Go to the top menu of the Android Studio and, Build -> Rebuild Project
Maybe your dependencies are not installed
Fire a terminal and type
pub get
Maybe this would solve the problem or try
flutter pub cache repair
first is open your flutter project, and call
flutter clean
flutter doctor
right click on android studio, then open Android studio, this way(not directly by folder)

Java class file not generated for new activity in Android Studio

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

How to fix Google Play Services 2 Library install to Eclipse

I've tried to follow https://developer.android.com/google/play-services/setup.html instructions in Eclipse for Mobile Developers (Juno), but am getting multiple errors with the library package after importing the library project into my workspace. I fixed the AndroidManifest.xml error it reported, but now I can't open the project in Eclipse saying the .project description file contains invalid information. So much for a simple install. I've tried uninstalling it, redownloading it, and I still get the multiple errors. Any suggesions how to get it working?
There is a misleading step in step 3 of http://developer.android.com/google/play-services/setup.html:
Copy the
/extras/google/google_play_services/libproject/google-play-services_lib
library project into the source tree where you maintain your Android
app projects.
If you are using Eclipse, import the library project into your
workspace. Click File > Import, select Android > Existing Android Code
into Workspace, and browse to the copy of the library project to
import it.
Don't do the first copy. Instead just do the second part and check the box that says "Copy projects into workspace". I found that if I did the first part I would end up with empty xml files.
Try the following :
https://developers.google.com/maps/documentation/android/intro#sample_code
You would get errors while opening an activity mentioned in the sample code. That is because android.support.v4.app.FragmentActivity is not added to your build path. Hover over the error and click on "Fix Project Setup". It would ask you to add the lib to the build path. Say Yes and enjoy :)
If your google_pay_services/libproject is empty (mine was empty) and looks like installed in sdk manager, first delete google play services from sdk manager, install it again and follow the steps in the first answer.
Try Window > Android SDK Manager > Extras > Google play service > Delete package.
And then re-install that package again:
File > Import, select Android > Existing Android Code into Workspace
I had the same problem. I went to Properties->Java Build Path and clicked on the Projects tab. Then I added google-play-services_lib using the Add button. This got me this run-time exception:
E/AndroidRuntime(9469): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
So then I changed the main.xml file entry from this:
android:name="com.google.android.gms.maps.MapFragment"
to this:
android:name="com.google.android.gms.maps.SupportMapFragment"
And FINALLY, it runs, but NOW no map due to authorization failure. So I am off on another search.
thanks Google for making it so complicated and for posting incorrect instructions!

Can't get Android ApiDemos to work in Eclipse

I feel a bit stupid since I develop android apps for a while now. My problem is that I can't get the ApiDemos to work with Eclipse.
Please have a look at the screenshot of my errors I get in Eclipse:
http://cheat-database.com/android.png
It looks like it can't find the xml files in the ApiDemos project. Although everything looks fine to me.
Any suggestions what I might be doing wrong?
Other (own) Android applications work fine in Eclipse.
Thanks a lot for help.
Do this: In Eclipse, File->New->Project, then either type the word "sample" in the filter text field or select Android->Android Sample Project and you will see all the projects such as ApiDemos, NotePad, etc.
The R.java is an automatically generated file. It is updated/re-generated whenever layout files, etc are changed.
I'm going to assume you tried to set up the project directly from the samples. I've seen that cause issues with write access if you don't have the privileges, and it doesn't seem to play nice when I try it either.
One thing to try would be copying the relevant ApiDemos folder to an alternate location and then try creating a new android project from that folder as follows:
Create -> New Android Project -> Create Project From Existing Source
Then point it to the location and select the relevant SDK.
It's not ideal, but at least it might get the application generating and running possibly.
Clean the project and build it again...I hope it would solve the issue
when you File->New->Other->Android Project from Existing Code, you have to tick "Copy projects into workspace".
got the same issue today :-(
this way gave me a solution very easy to use with ADT (eclipse) :
click on New Project icon --> Project --> Android --> Android Sample Project --> Next --> Select Target (for me Android 4.4) --> Next --> and then select the sample project you want to import in Eclipse (for me : legacy > ApiDemo) --> Finish
it works fine for me, i hope that could help someone :-)
#+Mathieu