Android Studio cannot resolve nested imports in dart files - android-studio

To explain my problem with an example:
I added the dart package carousel_slider to my Flutter project. According to the package documentation, all that's needed to use the package is
import 'package:carousel_slider/carousel_slider.dart';
This file is importing related files on its own, like carousel_controller.dart and carousel_options.dart. However, my Android Studio cannot resolve these imports and says "Undefined class 'CarouselController'" when I try to use CarouselController without explicitly importing the respective dart file myself.
How can I tell my Android Studio to resolve these "nested" imports?

It seems, there was an issue with the version of the package I had installed.
At first, I had ^2.0.0 in my pubspec. So I hardcoded it to 2.2.1 and ran flutter pub upgrade and now Android Studio resolves everything properly.

Related

Android Studio “cannot resolve symbol R” but project compiles and runs

Android Studio displays in all java files in red : “cannot resolve symbol R” but the project compiles and runs.
I have tried every solution here:
Android Studio "cannot resolve symbol" but project compiles and works, but with no luck.
I tried to :
invalidate caches and restart android studio
delete .gradle and .idea folders
clean and rebuild the project
install a new version of android studio
mess up with gradle file then undo changes and sync project
One thing that I want to try, but I don't know how to achieve, is to reopen the project from scratch as I was opening it for the first time, but I don't know how to do this.
I also tried answers from here:
Android Studio says "cannot resolve symbol" but project compiles,
but again with no luck.
Android studio version = 3.2.1
dependency versions in gradle project file:
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
classpath 'com.google.gms:google-services:4.0.0'
For some reason that i do not understand ,
this combination of build versions made the issue :
grade version = 4.10.1
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
when i switched to these build versions :
grade version = 4.6
classpath 'com.android.tools.build:gradle:3.2.1'
The issue was solved !
File -> Close project
Open an existing Android Studio Project
Open you project
Hope it will work.
sometimes, R file is not generated because of package name on android manifest is not match with package module that you have.
Is any wrong syntax or spelling in your xml?
Check your layout or any xml file.
Android Studio seems to have a caching issue with R.java occasionally. I rarely have a problem with this, but when I do, I actually open R.java (double press shift and type "R.java") or navigate to R.java under "app/build/generated/source" directory, opening the file and checking if the relevant XML id has been created. If it has, it forces Android Studio to now recognise the id's that are not being resolved. It's quick to try, and doesn't require clean and rebuild.
From your programs menu, open android studio. instead of opening your project from the recent files, select to open a project from your computer and then locate the path to your project. When all else fails, sometimes this works.
Also, try commenting out the support libraries from your gradle implementation, sync your project, and after sync fails comment them back in and sync again. (not sure if that's what you tried already when you said you messed with the gradle file)
In my case,
I am using
- Android Studio version 3.3.1 at home
- Android Studio version 3.2.1 at office
When i pulled projects to my office computer that are firstly created at my home computer ,
Android Studio can not resolved R file but runs application with no error. Because projects gradle and Android Studio version are incompatible.
Only thing that you sholud do, change the gradle version in project level gradle file
classpath 'com.android.tools.build:gradle:3.3.1'
to
classpath 'com.android.tools.build:gradle:3.2.1'
I was facing same issue,
first thought the issue might because of some xml file or naming of drawable resources incorrectly. After analysing, this case wasn't applicable to me.
So
Updating Android studio from older version 3.2 to newer version 3.3.2 along with new build tool version from SDK manager resolved this issue
for me.
I've tried invalidate cache and Restart AS with clean rebuild all the options but didn't work for me.
It says cannot resolve symbol, but it can run.
In my case, I just reload the needed *.jar files to the libs folder.
File >> invalidate caches/restart
Rebuild Project
Sync
Run
Works for me!
It looks like the library did not load my "imports" properly the first time.
That's why the import methods cannot be seen in my main_activity.xml.
This happened to me when I was going back and forth between different SDK versions.
Apparently SDK manager copied all the source files but it didn't finish cleanly. As a result I could compile and run my project just fine but IDE didn't recognize the SDK and reported all java symbols unresolved.
None of the above and other solutions in SO didn't work for me, but just uninstalling/reinstalling the specific SDK version did a job.
If you renamed your package (inside java folder), make sure you change your Manifest package name to the same
The only thing that worked for me was,
replacing,
import package_name.R
with
import package_name.*
simply go to project settings : settings.gradel and change the rootProject.name to your current name
rootProject.name = "write the project name here"

Android Studio cannot delete import library module

Cannot delete import library module. It will kept appeared after restart android studio or add new module even after delete it in Project Structure.
1) Module that I want to delete
2) Delete from Project Structure
3) Module still appeared after restart android studio or add new module
After update Android Studio from version 3.0.1 to 3.13. This problem happen to me and I have no problem with Android Studio 3.0.1. Can someone guide me about this problem
Check in your settings.gradle file there should be a line that starts with: include ':app'
You should remove the import to the libraries on this line, in your case something like:
':pipwavesdklibrary-debug', :pipwavesdklibrary-release'
Also remove the library from your project structure if no longer needed.

Android Studio error involving Markdown editor

I just installed a support package for Android Studio. Now it won't sync an Android project because of an error involving a Markdown package:
2016-11-15 06:24:07,147 [ 2770] ERROR - #com.intellij.lang.Language - Language with ID 'Markdown' is already registered: class com.vladsch.idea.multimarkdown.MarkdownLanguage
Is there any way to uninstall this package or tell Android Studio to ignore it?
Seems this is caused by Markdown Plugin (website), maybe by this issue, so you can either check if there's no newer version available or simply uninstall it unless the issue is fixed. If the issue above is not really the same, fill new bug report there's so author can take a look.

How to set building SDK in Android Studio 1.0?

I'm trying to import an eclipse project to Android studio 1.0.
First I get this message:
Error:failed to find target android-19 : ...\Android\sdk
Install missing platform(s) and sync project
But I don't want to install SDK 19, so I use F4 key on module to open settings, but then I get:
Error:(18) A problem occurred evaluating root project '2TVSSA-Library'.
Could not find method android() for arguments [build_9n8e326ws1pb1ogxq6eh7vjg0$_run_closure3#4815ddf5] on root project '2TVSSA-Library'.
I just downloaded Android Studio 1.0, but it tells me android() is missed? Does anyone know what I'm doing wrong?
Thanks!
The problem was an auto-created or imported module in the project. I can't modify the building SDK in root, since it does not have apply plugin: 'com.android.library'.
Change sub-module's build.gradle's android->compleSdkVersion solved the problem.

Grabble project sync failed

I have installed Android Studio. When I launch the program, there is the following error.
"Failed to find: com.android.support:appcompat-v7:10.+"
I have checked the SDK manager, Android Support Library and Android are installed.
Maybe my question appears to be stupid but I didn't find any answer.
[EDIT] I changed the
com.android.support:appcompat-v7:10.+
to:
compile 'com.android.support:appcompat-v7:21.0.2'
Now I have more than 400 lines of not found files:
http://pastebin.com/Sa4scRH1
In you build.gradle you have in the dependency section a line containing this string:
compile 'com.android.support:appcompat-v7:10.+'
replace it with this one:
compile 'com.android.support:appcompat-v7:21.0.2'
You are using there a quite old version of the compat library just use the newest one v21.0.2. If this still fails install the support repository from the SDK Manager.

Resources