After some hours of researching i still have a problem with my stdlib. I've imported lib just like it says on this link (https://intellij-support.jetbrains.com/hc/en-us/community/posts/206850425-How-to-use-a-external-jar-in-a-Java-application) but it still not working. When I type StdDraw.setScale(-100, 100); set scale goes red and intellij says "can't resolve symbol". I'm adding some screenshots so you can see what's the problem. And ignore name of Java classes i'm SLovenian haha ;-)enter image description here
Thanks for your time!
If you tried with project structure > add libraries > stdlib.jar and not working consider this:
I had the same problem and after a deep search I found the reason. You have to use a different stdlib.jar file. Download this stdlib-package and add import edu.princeton.cs.introcs.StdDraw;on the top of your .java file. (you can change StdDraw, Draw, StdIn, etc on top, your compiler will probably help you to import the right libraries)
OK I get it. Just import StdDraw class in src of your project and don't use a package. Then it starts to work fine.
Related
I am following this tutorial:
https://developer.android.com/google/play/billing/billing_integrate.html#billing-permission
No InAppBillingActivity file is generating. I'm not sure why. I checked to make sure everything is placed correctly but no luck. Here is what my folder structure looks like:
Click this for picture
Now I know there are similar questions like this but none of them were able to solve my problem. I have already imported googles billing library as well. No file generates when I run / build the app.
The problem is that the docs are not very accurate in specifying where it is that you will find the java file that should be in the gen folder. I had faced the same problem and had broken my head over it, until I found that the .java file was infact generated and it was in the path :
\app\build\generated\source\aidl\debug\com\android\vending\billing\IInAppBillingService.java
Its not a headache issue and your code runs smoothly itself without any interventions required. Hope this helps!
In android studio double click on your package name:
click in New and then on AIDL
Hope it helps
Its usually generated but not put where the tutorial tells you. If you do a Ctrl+N and type in the class name in intelliJ you may be able to find it
I was following a tutorial of Android and
When I was done everything, I got a problem in this code:
getDrawable(R.drawable.ic_launcher);
And I got the message
**"ic_launcher cannot be resolved or is not a field"**
What's more, my icon doesn't appear in tablet emulator,
but starts automatic.
What's going on?
replace "mipmap" with "drawable"
I had the same problem while following a tutorial and i found out that my AndroidManifest.xml file had the following code :-
android:icon="#mipmap/ic_launcher
so I changed R.drawable to R.mipmap it solved the problem . Wherever I found out drawable I replaced it with mipmap. Good to check for mipmap with android studio 1.1.
for more info :-https://androidbycode.wordpress.com/2015/02/14/goodbye-launcher-drawables-hello-mipmaps/
Check top line of your activity if have an import of
import android.R
delete it and clean your app.
Here is how I solved the problem:
In my program there had been android.R import so it was giving error for R.drawable.ic_launcher ....removing android.R import worked for me..!!!
You should check if under the dir gen there's a file called R.java. If so open it and check if there's an attribute called icon.
It could be that you moved your project or copied something from other projects. In any case you can remove the file manually under gen and let Eclipse recreate them. If not, you can go under Projects and then Clean choosing your project. It should work.
OR
I just thought I would add a quick additional answer to this topic. I am very new to Android development and had found that one of my classes was not compiling as it could not find any of my drawable attributes. In the end I tracked the problem down to the fact that the class was importing android.R (automatically added to the imports list by Eclipse). As soon as that line was taken out, the class compiled.
I am hardcore Noobie in Java (and Eclipse) and this is my 1st Java code.
I am using VMware Java SDK and I am able to run the Java samples that come with the SDK. In one of the sample codes, I find this line:
import com.vmware.vcloud.sdk.Organization;
And the line in which this class is used is:
for (ReferenceType vdcLink : Organization
.getOrganizationByReference(vcloudClient, orgRef)
.getVdcRefs())
Here I understand how Organization is imported and being used.
Now, I am writing my own code in Eclipse and not able to make "Organization" work. Eclipse is not writing the import (however, Eclipse is auto-writing the import statements for few other methods that I used from the same SDK)
Here is what I did:
I did make sure that I import all the .jar files (that come from the VMware SDK) into Eclipse at Project Properties -> Java Build Path -> Libraries.
I am also running CTRL+Shift+O to arrange the imports.
I have also set Windows > Preferences > "Save Actions" and checked "Organize Imports" so that it will arrange the imports every time I save the program.
However, I am just not able to get Organization work.
So from the sample code (which is working), I copied the below line to my code:
import com.vmware.vcloud.sdk.Organization;
But still it is not working. Needless to say, If I type Organization. and then do a CTRL + Space (to show autocomplete suggestions), it does not show any methods in the pop up.
I am thinking this is somehow related to the setting of the .jar file paths but I'm not sure.
Thanks.
UPDATE:
This is the error I get when I use "Organization": This error pops up in a box when I move my mouse cursor to the Red dot on the far left of the line where I wrote Organization:
Multiple Markers At this line
-Orgnization cannot be resolved to a variable
So,
I got it working as below. Not sure whether it makes any sense to you guys. But an explanation would be really helpful:
My sample code has below things:
In Eclipse, it is located in project->src->com->vmware->vcloud->sdk->samples folder
And it has this line at the top: package com.vmware.vcloud.sdk.samples;
So I move my code from project->src to project->src->com->vmware->vcloud->sdk->samples and added that package line to my code.
Now eclipse is writing the import statement for Organization as well as eclipse shows me available methods for Organization.
Now,
I don’t want to write my code inside the samples folder.
Is this even making any sense??
Thanks for the comments. I got this idea after reading your comments.
I am building an application and I added a new activity to generate a view. I compiled it. My application can not find anything that is on the format R.id.xxx or R.layout.xxx, I've tried also cleaning my project, closing Eclipse and opening Eclipse again, but nothing. The most strange thing is that before everything was working well. But now it can not recognize even the R.layout.main that is default of my principal activity. Anyone have an idea?
Also I have tried almost everything here: R cannot be resolved - Android error
but no result!
Solved
Thanks to woopsy, also I found the reference to this kind of problem
http://source.android.com/source/using-eclipse.html
it happens because Eclipse sometimes imports R when you press the combination ctrl+shift+O
Remove all your imports for the Activity and then have eclipse fix imports. I have had problems where eclipse wants to import a different R than the one I need.
First of All Check You have R.java File then check
import android.R;
Enter Yourpackages like import com.mypackages.prj;
If you are using eclipse, take a backup of your layout main.xml file and then from the eclipse new file interface create a new "Android XML File" and call it main.xml. copy back from the backup the contents into this new file.
try this.
check your xml files. there might be something wrong in it which is causing R not to build up automatically. To observe such errors, switch your view to Console tab
this is a common error. You need to just search your R.java file in generated section of your project directory in Eclipse. Need to import if the R.java file into the package then import . R;
I hope it will work for you. It was absolutely worked for me...enjoy programming
friends take care that u haven't imported R class, if you have delete "import android.R". The reason is there are two R things one R.java and R.class and we need the java, where we dont need to import rather than referring it. It worked for me and may be to you too.
I found the solution...For me works it
Poject->Properties->Android->Project Build Target (here choose android4.4 or 5.1.1 Android Open Source Project)->Ok
Project->Build All
This function ...
This problem can fix with this process: -
File---->Invalidate cache/restart.
it will restart your android studio and fix that problem
While trying the google plus API example from the project site I'm completely stuck with one import:
import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
This thing just doesn't seem to exist in the project.
The sample is a read-made Eclipse project I imported, and to be sure I checked if the massive amount of .jar's in the /lib directory are added to the build path. They are, I can see them listed in the Referenced Libraries part in my Eclipse project.
I can find mentions of com.google.api.client.googleapis.extensions.android2.auth but there just doesn't seem to be any GoogleAccountManager class around.
Several possibilities I have come up with, but can't find out which is it, let alone find a solution to them:
I have not set up my project correctly. I doubt it, but completely possible. This would mean that the example has a broken project set-up and/or I managed to not import all libraries?
The class or package or something like that is renamed // named differently. This would mean the example is broken out of the box, and that I still need to find the correct class (and change the import + calling code to that)
Something else :D
The following are the contents of the libs directory as you can also browse on the project page . Notice that it does containt google-http-client-extensions-android2-1.6.0-beta.jar
google-api-client-1.6.0-beta-sources.jar
google-api-client-1.6.0-beta.jar
google-api-client-extensions-1.6.0-beta-sources.jar
google-api-client-extensions-1.6.0-beta.jar
google-api-client-extensions-android2-1.6.0-beta-sources.jar
google-api-client-extensions-android2-1.6.0-beta.jar
google-api-services-plus-v1-1.3.0-beta-sources.jar
google-api-services-plus-v1-1.3.0-beta.jar
google-http-client-1.6.0-beta-sources.jar
google-http-client-1.6.0-beta.jar
google-http-client-extensions-1.6.0-beta-sources.jar
google-http-client-extensions-1.6.0-beta.jar
google-http-client-extensions-android2-1.6.0-beta-sources.jar
google-http-client-extensions-android2-1.6.0-beta.jar
google-http-client-extensions-android3-1.6.0-beta-sources.jar
google-http-client-extensions-android3-1.6.0-beta.jar
google-oauth-client-1.6.0-beta-sources.jar
google-oauth-client-1.6.0-beta.jar
gson-1.7.1.jar
guava-r09.jar
On the first page is a link to updated Google plus libraries google-plus-java-starter_v5.zip
Updated Link: google-plus-java-starter_v5.zip
It contains android/libs/google-api-client-extensions-android2-1.6.0-beta.jar, which contains GoogleAccountManager class.
As this is an extension it probably needs other jars too.
(summary of comments)
Manually adding /libs/google-api-client-extensions-android2-1.6.0-beta.jar to the build path and verifying that it is in the Referenced Libraries fixes the problem. It is unknown (to me (Nanne)) why this doesn't happen automagically when adding the libraries, but there you are.
Right-click on Project, select Properties->Java Build Path->Order and Export Tab->click on checkbox for “Android Private Libraries”. That worked for me.