I downloaded the Android Development Tools SDK which include Eclipse and SDK.
The Eclipse IDE crashes when i try to write a line that include "R.", like:
EditTex Password= (EditText)FindViewById(R.id.pass)
It won't show the error, it just crashes.
You should use: R.id.yourControlId
In the autogenerated class R are you're ID's stored for multiple things like your resources; images/strings etc..
To get your images from your drawable folder: R.drawable.image
To get your string from your strings.xml: R.string.hello_world
So you should do this instead: EditText Password = (EditText)FindViewById(R.id.pass);
I have the problem, too, seems to be a bug in the openjdk in connection with the ADT. This has nothing to do with the code you write in eclipse. It can be triggered in more ways. And it seems that it is no problem with eclipse itself, because it is no Java-Exception but the javavm that segfaults. Looking for a workaround myself atm.
Edit: May be this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404776
Edit2: And this here may be a workaround: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404776#c7
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'm trying to use JRuby in projects created in Android studio. I have built the latest (as of 9/10/2014) JRuby, and have completely updated Android Studio. I have a working app that I can use to test. I have a copy of jruby.jar in the MyApp/app/libs directory. Once there I right-clicked on jruby.jar and selected "Add as Library", which presumably did something (though what I am not certain), and have added the line "compile files('libs/jruby.jar')" to the build.gradle that is in MyApp/app/.
In one of the class files I have "import org.jruby.embed.ScriptingContainer;", which Android Studio says is fine (if I hadn't added jruby.jar as a library I couldn't include this without an error). Then in one of the working methods I say "ScriptingContainer container = new ScriptingContainer();". When I run this method the app will crash. I won't try to include the whole error message, but the important part seems to be:
Caused by: java.lang.ExceptionInInitializerError
at org.jruby.embed.internal.AbstractLocalContextProvider.<init>(AbstractLocalContextProvider.java:42)
at org.jruby.embed.internal.SingletonLocalContextProvider.<init>(SingletonLocalContextProvider.java:88)
at org.jruby.embed.ScriptingContainer.getProviderInstance(ScriptingContainer.java:248)
at org.jruby.embed.ScriptingContainer.<init>(ScriptingContainer.java:228)
at org.jruby.embed.ScriptingContainer.<init>(ScriptingContainer.java:185)
and
Caused by: java.lang.RuntimeException: unsupported Java version: 0.9
at org.jruby.RubyInstanceConfig.initGlobalJavaVersion(RubyInstanceConfig.java:1858)
at org.jruby.RubyInstanceConfig.<clinit>(RubyInstanceConfig.java:1608)
At least, those are the parts that make sense to me. I hav no idea why I would get the error "java.lang.RuntimeException: unsupported Java version: 0.9", since I am using 1.8.0_20. The rest of the errors I cannot follow. When I click on any of the files giving me an error (say AbstractLocalContextProvider.java:42) Android Studio will show the file but also say "Sources not found". That could be the problem, but I don't know why it can't find the sources.
Thanks for any help,
Brian
Uwe Kubosch (#donv70) was able to tell me the solution to this via Twitter, so credit to him, but I wanted to post the solution here in case anyone else needs it.
It was Java version that was causing the problem. In Ruboto the problem is solved here: https://github.com/ruboto/ruboto/blob/master/assets/src/org/ruboto/JRubyAdapter.java#L137
and for use in Android Studio it is necessary only to include the line: System.setProperty("jruby.bytecode.version", "1.6");
The number of course can be 1.6, 1.7, or 1.8, depending on your version of Java.
Looks like an interoperability problem between JRuby and the Dalvik VM (don't forget that you're running against Dalvik, not the Java VM).
There's a bug report at http://jira.codehaus.org/browse/JRUBY-5774 that may lead you in the right direction.
It's kind of old, and is marked 'fixed', but maybe it'll provide some clues?
I've just installed the SDK and all the stuff necessary for programming Android in Eclipse for the first time, and I've just find my first problem. After opening a sample project (Snake, for 2.2), there seem to be errors in the code. Well, the R library was not imported. I don't get why it was not already there, but I've imported it. All good? Nope! text = getString(R.string.tie);still has an error. Same with the rest of code (when it uses R). tie is not recognized, it's not shown in that usual blue of Eclipse.
Eclipse says that the problem is ADT 14... final stuff, or switch statements. Ok... I've read that. There's no switch there. That's not the problem. Eclipse suggests me to change .tie to any other thing... like button1. That's not useful, of course. I think the problem is R class, not ADT. Or maybe R class has some final statement so it is not accepted.
I've tried to see if it was that and, in opening the R.class, I get this message: "The source attacement does not contain the source for the file R.class." What now?
R is not a library, it is a resources file, which is generated automatically during the build from existing resources. Just make sure that resources are properly placed where they belong. Then build the project and everything will be OK.
try using project-->clean in eclipse.
if you imported R library remove it. and try again
Make sure you have the required package installed in the AVD Manager. Then, check your Problems view in Eclipse and look at all other errors, other then the R-related ones and make sure everything else is fixed first. If you have an error anywhere in your XML layouts for example, R will not generated.
I am trying to use the following code
https://github.com/harism/android_page_curl
I selected Create Project.Use the current source. Pointed it to the directory and click on Run. Following are the errors I am getting. Any idea ?
Try cleaning and building again. If not, it's likely that Eclipse is not recognizing your Android SDK install location. Check it under your Android preferences.
check this out 'Must Override a Superclass Method' Errors after importing a project into Eclipse
i would be willing to bet its the same issue, you can post some code but i dont think the #Override is there for the methods indicated in the error picture
I have re-started Eclipse, re-run the application numerous times, and saved all of my files in my application. In my .xml, I have gotten rid of a button.
The .xml is inflated in my .java file. However, when I run my application on the Android emulator, it keeps showing the button that I deleted.
reinstall the application, clean the project in eclipse.
One possibility is your emulator is not connected to the ADB (Android Debug Bridge)
To check just do:
cd C:\Program Files (x86)\Android\android-sdk\platform-tools
adb devices
You should see
List of devices attached
emulator-5554 device
If you don't see this, manually kill the adb.exe process (DON'T kill your emulator).
Then manually run adb.exe again.
When you do adb devices you should now see your emulator. If you close/kill your emulator you may have to repeat the process again.
I would have thought that restarting Eclipse would have had the same effect anyway, but for what it's worth, always try Project -> Clean in situations like this.
Clean the project and then run.
OK - I tried all this and it did not work (but I did resolve the problem...).
My project is very simple, as I am a complete newbie and had only created a mock up of the app - a simple interface and adjusted the strings XML file. None the less, I wasted a couple of hours trying to fix this damn problem. In the end, I simply generated a new project and ported all my work over. This took 10 mins and worked perfectly.
To try to learn why this happened, I repreated the steps that seemed to have caused the problem (clearing all projects, and then building them all again) - having copied all the code fromt he original project (including the manifest). I could not break it again, so am none the wiser about what caused it.
A more complicated project might be more of a challenge, but I thought I would post in any case, as I wasted a lot of time trying all these other things without sucess.
Uninstall the application from Setting->Application->Manage Application->Select Your app->Uninstall. and then run.It will work
To detail Rasel's answer (in addition to Project...Clean) you can also go to a shell and type adb uninstall com.example.applicationname.
The problem happened to me when I imported the project using the orginal files in Eclipse. It worked after I imported the projekt into the eclipse workspace as a copy
I had the same problem in Android Studio. When I added an imageButton it was visible in preview tab of Android Studio, but not in the emulator. I tried almost every solution mentioned in Stack Overflow for similar situation, but I didn't succeed. One of answers said that you should create a new project and copy your files into it, but this solution had a huge cost for me and I didn't want to try it. Finally I renamed my layout file in the onCreateView method:
View view = inflater.inflate(R.layout.fragment_story_edition, container, false);
Then I created a new layout resource and left it empty and ran the project in order to get an error. After that error, I copied the content of my original layout file to my new made layout file, and the problem was solved.