Android Studio No "Import Sample" option in File menu - java

Why android studio not showing import sample option in File menu even
if I have downloaded sample projects on my disc?
I have Android Studio 2.2.2 with correct sdk path.
It's a bug? or ??

To see this menu option:
File -> New -> Import Sample
you need to turn on:
Settings -> Plugins -> Google Cloud Tools For Android Studio

Have you checked "Google Developer Sample" plugin option?
In my case, this option had not been active.
Settings -> Plugins -> Google Developer Samples.
After checking this option, I finally could import sample project.

As a workaround, you can import samples (eg, examples here) from Git with File -> New -> Project from version control -> git

You should go to File -> New -> Import Sample.

If you search for a example for a specific programming problem, you can now right click on some code e.g. viewpager and choose:
find code sample
.
On the bottom a window appears with example having the same construct. You can now double click and the browser opens and brings you to the git server with the example. From there you can download.
Before you had to browse the examples to find a specific example for your problem, now you can search. This might be an advantage.
I use android studio on mac. Version 2.2.2.

Related

How to import org.opencv.android.JavaCameraView?

I'm trying to use OpenCV 2.4.10 for Android in Eclipse.
But my example project cannot compile because of Eclipse can't find the org.opencv.android.JavaCameraView package.
See the picture please
http://prntscr.com/5wt2ek
How to fix this problem?
Have you add the OpenCV?
Like explained here:
Add OpenCV library project to your workspace. Use menu File -> Import -> Existing project in your workspace.
Press Browse button and locate OpenCV4Android SDK (OpenCV-2.4.9-android-sdk/sdk).
See more information:
http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html

In Android Studio, method comments not showing in intellisense

I am developing Android application using Android Studio IDE and I can't find any public API comments in IntelliSense list. Do I need to install some plugins?
File -> Preferences -> Editor and check "Show quick doc on mouse move".
Also make sure the option "Autopopup documentation in (ms):" is checked under: "Code Completion"

Running Android Support v4 Library Demo Programs

I'm interested in running the Android Support library demo projects for the v4 library.
Using the Android SDK manager I've installed the Eclipse plugins, and APIs from 2.2 to 4.0.1. There are several issues involved, and the sample project as provided is far from running on my configuration, as downloaded.
To reproduce this error:
Install SDK and Eclipse Juno
Import the sample v4 compatibility project using File --> New --> New Project and choose "from existing code", targeting, for example, the Support4Demos folder in <Android-sdk-path>/extras/android/support
Open the file AccessibilityManagerSupportActivity.java. The following errors appear.
Open res/values-v11/styles.xml. The following errors occur.
How do I get rid of these errors? I'd also like to understand why they are appearing so I can fix them in the future.
Thanks!
Clean solution is to:
Right-click your project.
Choose "Android Tools"
Choose "Add support library".
Install the appropriate support library (the newest)
I can't really answer you on the why this problem happens, but I'm guessing the Android team doesn't supply the Android support library, because it's changing all the time, so not to get stuck on some older version, they want us to supply it on our own.
If errors still persists or new errors come up, right-click the project again and choose "Android tool" -> "Fix project properties"
Update: In conjuction to my answer, the way to remove the rest of the errors is to import the project another way than you did.
Select File -> New -> Other
Click Next
Write Android Sample
Select Android sample Project and click Next
Now add the Android support librarys as described above.
You will get errors still however. To fix these, do the following:
Right-click your project and select "Properties"
Select Android
Select an SDK version equal to 3.0 or above
Select Ok and clean the project from the project menu.
All done ;-)
Now you won't be able to run the sample project on devices lower than Android 3.0.
The reason is because of some dependencies on some themes and settings, that wasn't added before Android 3.0 apparently.
It doesn't make sense why Google did this, but they did. You could try to remove the SDK +11 (Android 3.0) specific dependencies, but it will take some time - there are more errors than you actually see - especially in the XML files.
You have to add the v4 support library.
In order to do that , please follow these steps :
Select your project.
Click on Project from the menu.
Select Properties.
Click on Java Build Path.
Select the Libraries tab.
Click on Add External JARs.
Select the main directory of the Android SDK that you installed, then go to extras -> android -> support -> v4 , and then select android-support-v4.jar and click on Open.
Click OK.
This should remove the errors.
Please check your libs folder has android-support-v4.jar is present or not. if not add this jar file in libs folder.Just copy the android-support-v4.jar from any project and paste it to the libs folder of your project
I spent a whole night on this but can not solve this problem.
I finally solved the by accident: change some file in the demo and save, then change it back, this cleared all the errors. I think when you change some file and save, eclipse build the project and generate the R.java.

Eclipse: Tons of Errors in Android Application

I imported my current Android Project to Eclipse on my (Mac OS) device via SVN.
The code shows up alright, but Ecipse shows tons of errors (see screenshot) which do not appear on the device I first used - I am not very experienced with Eclipse but I guess some libraries were not imported?
I installed the current JRE(1.7), Eclipse, the Android plugin which also installed the current Android SDK (4.1).
Any clues?!
Place the sdk path in Window->Preference->android.
And then Click apply.
If you already do it. Then right click the project and goto Properties->android->select android version
Right click on Project -> Android Tools -> Fix Project Properties
Go to menu -> Project -> Clean
For that go to each java file import all required packages or try CTRL + SHIFT + O
then resolve all errors in RES folder.
Then it will generate R.java for you
then import yourpakagename.R; where ever required.
remove import android.R;
hope this will help you

Android Build Target cant be selected in eclipse

I followed these tutorials to set up a Hello World Android app. But when I create a new java project I can't select a build target. It just says no targets available in the target selection box. I have confirmed that I am not having the UI issue described here (http://blog.rowancrane.com/2009/12/27/eclipse-new-android-project-cant-select-build-type-target), I actually have a message in the box saying there are no targets instead of an empty box. I also am using 1920x1080 res.
I'm guessing that eclipse is just not aware of my Android Targets? I installed them in the android SDK manager and see them listed under installed packages in the Android SDK manager (1.1, 1.6, ..., 2.2)
http://fyi.oreilly.com/2009/02/setting-up-your-android-develo.html
http://developer.android.com/resources/tutorials/hello-world.html
Any suggestions on how I can create the project and get started?
Thanks in advance
In Eclipse, do this:
Window -> Preferences -> (In the field "SDK Location", add your path to your Android folder, e.g. "C:\android-sdk-windows" and then click "Apply" -> OK.
Now you should be able to select a target.
For MAC users,
In Eclipse, do this:
Eclipse -> Preferences -> Android -> (In the field "SDK Location", add your path to your Android folder, e.g. "/Users/user/Projects/Android/android-sdk-mac_x86" and then click "Apply" -> OK.
Now you should be able to select a target.
Please make sure that at least one version of Android SDK is installed. To check this, go to window > Android SDK Manager.
Don't create a Java Project, instead create an Android Project. In the setup steps you can define a build target. Hope this helps.
just upgrade android sdk ools to rev. 22.6.2 n problem will be solved,at least my problem is solved

Categories