I've been having some struggles with building my app after Reinstalling Android Studio. The cues I've gotten have been related to either Java location or installation. With the jre already installed it seems more likely not to be an issue with JAVA.
I've tried importing my project, copy and pasting from .txt files, reinstalling java, redefining java PATH, changing build dependencies, downloading command line sdk manager to build outside of the ide, erasing build caches, and I also let Android Studio rewrite properties.profile when importing Android Studio Project.
Another strange thing, when I create a directory in the project structure it shows up when the ide is initiating before gradle builds. After gradle builds the folder is no longer visible.
EDIT
error: package R does not exist
error: cannot find symbol class appcompat
UPDATE
This seems like a common problem. I've tried to follow most of the current questions on java incompatiblity but still haven't come up with a work around. I downloaded oracle's jdk (unnecessarily) and pointed the studio project at it. Created a shortcut using the jdk java.exe and placed it in Studio core, added java to the PATH which allowed gradlew build in the terminal to initiate but not complete. What are the next steps?
UPDATE
Just in case somebody else stumbles onto this. This post and also this one got me there.
The fix ended up being an import of the .R file. com.example.android.recyclerview.R Hope it can help
Related
I'm getting the following error when I try to run my App on my SmartPhone:
Didn't find class "munyul.game.android02.android.AndroidLauncher" on path: DexPathList
Due to HD issues, I was forced into rebuilding my machine and setting up my developed environment again. After a lot of messing around, I have the following installed and working:
Java 1.8
Eclipse Neon
libGDX
Android SDK Manager
The Android App in question was almost finished, but now that goal seems like a long way off :(
I used libGDX to create a new project, and then I copied the old code into the new project - this is where things got messy.
I had to fix several errors caused by changes in libGDX, which was easy. I then also had to fix several errors caused by changes to Google Services, this was not easy! I eventually read about the new m2repository folder, then I searched for and found the class files needed (play-services-ads, -base, -basement, -games and -plus, inside .aar files), placed all the classes.jar files into their own directory within the android/libs project folder, finally adding references to them from within Eclipse - now everything compiles and looks good (should these .jar files be checked for export? - see edit)
Finally, I had to make one more change; the old project/code was created with a package: munyul.game.android02.android, but the new only had munyul.game.android02, I added the missing package to the new and also updated the AndroidManifest.xml file (maybe this is what went wrong!?).
I've checked the code and manifest and everything looks correct, but when I run the App it instantly crashes with the above mentioned error.
Also, I've checked the Order and Exports for the android project, the boxes that should be checked are.
Anyone know what else I could try?
EDIT:
As a test, I checked the Google Services JAR's for Export, and now I'm getting a different error:
Could not find class 'android.support.v4.util.ArrayMap', referenced from method
com.google.android.gms.common.api.GoogleApiClient$Builder.<init>
I'm starting to think that my error lies with how I resolved my Google Services issues - is there a better way of linking the missing classes? Somehow adding them via Gradle?
EDIT #2:
I migrated the entire project to Android Studio - now the APK installs and runs correctly on all my devices.
Honestly, I would have prefered to stick with Eclipse, but it seems like that is no longer an option - HTH
Check your AndroidManifest.xml for the correct application class (or none if you are not overriding.) The AndroidLauncher is part of the "instant run" feature available in Android Studio and is automatically injected by gradle into the manifest file.
Eclipse is no longer a supported development toolchain - you'll want to do your migration to Android Studio (or IntelliJ) sooner rather than later.
I am trying to setup a new Android project with Mapsforge. I know that people have been getting this issue because the library requires Java 7 to build. However, I am using Build-Tools verson 20, which uses Java 7. I also have the latest updated version of the Eclipse tools. In fact, I am on a clean install of the Android Developer Kit.
So far, I have imported mapsforge-core, mapsforge-map, mapsforge-map-android, mapsforge-map-awt, and mapsforge-map-reader.
I then tried to initialize a MapView using the following code:
AndroidGraphicFactory.createInstance(thisApp);
This results in the following error.
java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory
I looked in the referenced libraries, and the AndroidGraphicFactory class is defined within org.mapsforge.map.android.graphics and shows up. When looking at the jar file within /bin/dexedLibs\, the classes.dex file exists, but there is next to nothing else.
I followed the steps suggested by this answer, but the error persists.
Any ideas as to why this might be?
You need put the jar file into the libs/ folder insted of add reference on java build path.
guys, with my friend started working on a school project - developing a java app for android. He started it, now it's my turn to do my job, so i got the code he already has, set up Android SDK for Eclipse and downloaded all the neccessary files and packages, but it still gives me errors and I can't even run the project.
One of the errors (the main one, I think) is that it can't import android.support.v7.app.ActionBarActivity
If anyone knows what can I do (I've tried all kinds of solutions from the internet, but none work) I would be very grateful.
Here is a screenshot of the code
http://s17.postimg.org/8aw952lha/Capture.jpg
See if you have imported the ActionBar project to your Eclipse workspace, also, right click on your project->properties->android and check that you have referenced/linked the ActionBar project there.
If you are using a repository without the proper ignore files it is possible that you have imported your partners configurations and then have the references to the auxiliary projects broken (you just need to update that).
Hope it helps.
android.support.v7.app.ActionBarActivity is a support library. This allows older versions of Android (before native support for an action bar was available) to use the action bar.
Since you are having difficulty importing it, I'd assume you do not have the support library installed.
Full instructions are available here:
http://developer.android.com/tools/support-library/setup.html
A snippet for adding support libraries to Eclipse:
Make sure you have downloaded the Android Support Library using the SDK Manager.
Create a libs/ directory in the root of your application project.
Copy the JAR file from your Android SDK installation directory (e.g., /extras/android/support/v4/android-support-v4.jar) into your application's project libs/ directory.
Right click the JAR file and select Build Path > Add to Build Path.
New to android dev world and am just getting started here, well trying to anyway. I've downloaded Cordova (2.8, might need to upgrade this), Java JDK (1.7), and the new Android Studio, the Andriod SDK, installed all the 4.x packages with that, and installed ant (1.9.2).
Everything seems to be working as far as that goes. Problem is when I can create a Cordova project, from the command line, load it up in Studio using the import feature, not tweaking anything, just accepting (as I read to do so on some blog out there) and everything seems to load ok and the project is there in Studio, until I try to make it. At this point, I get and error "java: package org.apache.cordova does not exist" This is followed by several other errors, which I feel may be related. I'm not nor am I trying to do anything fancy here, just get the stock up and running.
Anybody know what I'm missing? Do I need to copy a file somewhere or compile something extra? Or am I using the wrong version of something?
Thanks!
I found after hours of searching and trial and error (although mostly errors) I came to find that it was all due to missing the cordova-*.jar file. which needed to be built using the ant jar in the framework folder of my android cordova directory. This step had been majorly left out of a ton of documentation. Once built, I simply copied this into the 'libs' folder of my project and everything loaded up and ran, although I did get a warning about depreciated project from the compiler, creating an ant build and selecting 'external compiler' fixed this warning.
Android Studio uses Gradle project layout. This means main java files should be in /src/main/java. If Cordova generates different structure (it looks like it is old Ant structure) you need to add its source folders to build.gradle
android {
...
sourceSets {
main {
java {
include 'some/wanted/package/**'
include 'another/wanted/package/**'
exclude 'some/unwanted/package/**'
}
}
}
}
Here is where the file sits:
When I work on an android application in Eclipse, R.java never appears. I did the following to try to fix it:
delete ~/.eclipse folder
reinstall eclipse
create a new workspace
reinstall android developer tools
reinstall operating system
None of it worked. Even the Hello World! application that is created by default won't build. What do I have left I can do?
UPDATE:
There aren't any problems in Problems other than the two "R cannot be resolved to a variable"s. The Error Log tab shows an error Failed to load properties file for project from when I created the project. I think that may be a good clue as to what the root issue is.
ANOTHER UPDATE:
It's not a permissions issue, since the same thing happens when I run Eclipse as root. 'Fix Project Properties' does nothing. When I comment out the references to R.java, the problem is not resolved (the reason it doesn't run is [2013-07-08 21:47:37 - AppName] Could not find AppName.apk!
)
YET ANOTHER UPDATE:
running eclipse as root works now.
OS is 64-bit Arch Linux
Make sure that you have no xml related error( open and check all xml files, including the manifest manually).
Clean your project.
Change the build target version.
Make sure that you have Android SDK build tools. It comes on updating the ADT plugin.
Try these things:
Check in the properties of the project, in the Android tab if you have downloaded the version of the API that you are using. (See this in the SDK Manager)
Look into your /res folder. Scan for every file. Does any one has problems? If one resource has a problem, the R.java file is not generated.
Check the AndroidManifest.xml file. Look for warnings or problems, especially the use of the <uses-sdk> tag.
If none of these appointed the problem, try to build a simple java application. Does it work? Are you using the JDK 1.6?
Finally, if you are still stuck, download the Android ADT and use it as your IDE. It has all you need.
If your O/S is 64-bit Linux you will encounter Problems with the ADT because it is a 32-bit application. You have to install the following 32-bit libraries:
sudo apt-get install ia32-libs