org.opencv imports okay, but not org.opencv.android? - android

I've followed these instructions for adding OpenCV to a gradle project, and it seemed to go okay, however in my source I can't import the OpenCV classes.
org.opencv seems to import ok, but not any of the sub-packages or classes. In Android Studio it looks like this:
As I type out the package name, after org.opencv. the only suggestion is *.
What could I be doing wrong?

I have had this issue with Android Studio a couple of times
I find it is resolved by closing and reopening the project when the project reloads it has worked.
If that does not work try close and reopen Android studio.
The third thing you could try is |File|Invalidate Cache Restart| .

Related

Android Studio imports Kotlin Dependencies into Java File

I recently had to reimport my android project, which consists of both .java and .kt files, into Android Studio. After the import Android Studio tries to import only some Kotlin dependencies into .java files, what obviously doesn't work.
The same code had worked before, what makes me think I may be missing some setting in Android Studio, about how Java and Kotlin interact or something like that?
Edit: On the other hand I'm able to build my app and also deploy to a device without problems, but Android Studio still keeps complaining.
Check your kotlin version(make sure that you have the latest one ) then clean and rebuild your app
try to hard-import
import java.lang.Deprecated;
but I think you can resolve this issue by the way clean and rebuild your project

Cannot resolve symbol FragmentPaperAdapter

Ok...
I've got an issue I don't quite understand.
I've created an application for the past week, and decided do make some changes. So I started again from scratch. So I create my main activity, I feel it, I create a second activity which is supposed to contain tabs (I just add the add activity feature of Android Studio) and now I get errors like this:
Cannot resolve symbol FragmentPagerAdapter
on line: import android.support.v13.app.FragmentPagerAdapter;
or Cannot resolve symbol ViewPager
on import android.support.v4.view.ViewPager;
The project builds all right, and run on my phone, but I have all these errors which is really annoying and not helpful. I read somewhere that the Android Support Library should be installed, it is if I trust the SDK manager. And it's really weird since it's working in the other project.
What should I do?
Thanks
[EDIT] typo
[EDIT2] Tried to restart the IDE, clean caches and clean/rebuild the project. Nothing worked :/
Apparently I finally solved it. I named my application with a ! at the end. Which means that when creating the project, the root folder got a ! in it, which apparently broke the IDE.
I created a new project, kept the app name but removed the ! from the folder's name, and it works again...

Errors when importing someone else's projects - Android/Eclipse

I have been using Eclipse for about 6 months now, and I noticed that I rarely can import someone else's project into Eclipse. I get so many errors in many files. For example, I tried to import a friend's project that I know works just fine, but I get a lot of "R" errors, like Eclipse can't recognize "R" as a field, and then other weird ones like ActionBarActivity is not recognized or an entire imports like android.support.v4.app.Fragment that visually are in the library but are not being recognized by Eclipse as being there, and I check them and they are definitely marked "Is library" and added properly to the project. Anyone know why this is or how to fix? It's frustrating because to learn, sometimes you need to see someone else's app run first, then look at their code, but you can't. Thanks in advance.
My usual way of importing a project is to do File -> Import -> General -> Existing Projects into Workspace. Also, I have tried cleaning the project, but it doesn't work.
try this File -> Import -> Android -> Existing Android Code into WorkSpace ->then browse-> select your project->make sure the checkBox"copy the project into workSpace" is marked
Check your Build Path. In the Android Section, try using some other API level click on Apply and after your project finishes with the building workspace, again revert back to the original API and click on OK.
Also check for any Build Path errors.
So thanks to the help of everyone of this post, and others on another post, the problem was finally fixed and took several steps.
Turns out that the ActionBarActivity error had a quick fix (hover over it, you get quick fix options) of importing the appcompat_v7 library. I never chose that before, because I thought it was already installed, hence the conflict with android-support-v4.jar (meaning there were doubles of that library), but I chose to import it anyway and that error went away.
But I discovered that android-support-v4.jar was actually a component of appcompat_v7, so that was causing the "Jar mismatch!" error in the console. So I deleted android-support-v4.jar from the libs folder, and the jar mismatch went away.
Lastly, my layout files were all not being recognized, even though I knew the variable names were all correct. So the error was from when I tried to refresh my imports in the very beginning of the problem (using shift+command+O), thinking it was an import problem (which it was), but at that time, refreshing did nothing. BUT... Eclipse took away import com.laurengariepy.android.gridimagesearch.R; and replaced it with android.R;, which is what was causing all the layout errors. So once I put that com.laurengariepy.android.gridimagesearch.R; back, then all errors went away.
So the take-away to this story, is be careful with Eclipse version 22.6. The auto-import of the appcompat_v7 library will cause a lot of trouble when you try to import other people's projects, because they were likely not created in an IDE with appcompat_v7 already there.

importing R. (android)

I have searched through Stack Overflow as I know this is a common question, but none of the solutions seemed to work for me. This included cleaning my project, deleting all imports and deleting the project and starting again entirely.
I am using the Eclipse specifically for android on mac (ADT bundle mac).
Whenever I create a new project I have errors immediatley in my src folder on the line
setContentView(R.layout.activity_main);
and also on inflate.
Any suggestions other than those stated? It is literally before I have done any programming so cannot understand what is wrong.
EDIT: Fixed. Downloaded the SDK a second time and this seems to have fixed it.
import The R class. The basic syntax is
import your_application_package_name.R;
If you have already imported it but it is not working then check if there in any error in your resource xmls. If so then r can be not generated and that error will be shown
Change your Project Build Target to the Latest
Right Click Project > Properties > Android > Change the Api to latest version
Try to update the Android_SDK. When you create or import a new Android project the SDk builds the project. The R problem is mostly an update SDK problem.

Error when importing com.google, com.android.internal.Telephony, etc

I've downloaded the android source code for CallLog, Contacts, Dialing from here.
But now, when I try to import this package on Eclipse, imports like:
com.google,
com.android.internal.Telephony,
com.android.internal.R,
com.google.android.collect,
android.provider.ContactsContract.Intents.UI,
android.provider.ContactsContract.SearchSnippetColumns,
android.provider.ContactsContract.ProviderStatus,
android.provider.ContactsContract.ContactCounts,
android.content.IContentService,
android.provider.ContactsContract.Intents.UI
And many other imports, show errors saying it cannot be resolved.
So my question is, why it shows this errors? Why I cant implement it without this errors? I use the Google APIs, I've created the project from an existing source code, but I dont know why this happens.
If you're sure that you have set up the Android SDK correctly, you should try to 'clean' your Eclipse project.
This usually solves import related errors in Eclipse for me.
Try right clicking the solution / project in the project explorer and choose "fix" near the bottom.

Categories

Resources