I've tried, with zero success so far, to both create a new project and add GoogleCast to it and to get the given examples to work on Android Studio (currently using 0.3.2, but will upgrade if needed) on MacOSX.
Migrating to Eclipse, however, is not a valid option at this time.
I always seem to end up stuck with some reference issue, either giving me the error "No resource found that matches the given name '#style/Theme.AppCompat'." or multiple compile-time errors related to having no idea where android.support.v7 is located at.
Tried many different solutions, such as removing the #style part that someone mentioned to work or setting the v7 path as relative.
Though I wasn't able to follow through with this last one, no idea how to actively do that in AS and not enough reputation to comment there.
Then I came up to this solution Anyone get the chromecast android examples working in android studio?, which seems like a good attempt, except I can't seem to find the mentioned GoogleCastSdkAndroid.jar anywhere, so I'm stuck.
Couldn't find a truly comprehensive tutorial anywhere either, since they all seem to have no issues whatsoever adding v7 to the project.
Thanks in advance for anyone who can donate some of their time to solving this issue.
EDIT:
After upgrading to 0.4.6 (is 0.5.1 stable already? Considered how fast it came after 0.5.0...doesn't sound too good); I did what Ali Naddaf suggested, but couple extra questions popped up:
I could build the CastVideos project and import it into Studio with no problem; however, the CastVideos project structure is radically different from a new project's structure (referred to as OtherApp from now on).
The main issue that pops up when I try to mimic CastVideos on OtherApp is that it doesn't find the CastCompanionLibrary project on the OtherApp only, which I can't seem to be able to figure out where exactly should be located at (I thought the 'core' folder was the one with AndroidManifest?).
Also, how do you import modules now? The Project Structure only allows the creation of new modules.
My suggestions:
update your Android Studio
open SDK manager and make sure you have the "Android Support Repository" installed
create an empty directory on your system (referred to it as <DIR> below)
change directory to <DIR> and clone CastCompanionLibrary-android to CastConpanionLibrary
$ cd <DIR>
$ git clone https://github.com/googlecast/CastCompanionLibrary-android.git CastCompanionLibrary
$ git clone https://github.com/googlecast/CastVideos-android.git CastVideos
first make sure all is fine by building from command line:
$ cd CastVideos
$ ./gradlew build
it should do a successful build at this point.
if all is fine, open your Android Studio and select "Import Project" and point to build.gradle in the CastVideos project.
Now for any other project, you can look at the build.gradle in CastCompanionLibrary or CastVideos to see how you can set up your dependencies on the support libraries; if you don't have dependency on the CastCompnionLibrary, then it is even easier.
You very much need to upgrade Android Studio. 0.3.2 is quite old and a multitude of bugs have been fixed since then that are almost certainly affecting you.
Other than that, make sure you have the Android Support Repository installed in your SDK Manager. Between those two it should solve your support.v7 errors and #style/Theme.AppCompat issues.
This question is very old but to make it work I had to clone both Git repositories (CastCompanionLibrary & CastVideos-android). Import CCL into Android Studio as Non Android Studio Project, change the version of build tools to current 21.1.10, build the project and close it. Android Studio asked me to reopen the project. Hit yes. Do exactly the same with CastVideos-android and finally I could launch it into my smartphone.
Was really painful, took me 2 hours make sense of the error, because I was trying to open into Android Studio like Android Studio projects (they were) but there was a problem with the .idea file.
Tried this and everything worked.
Related
I know this question has been asked before, but there wasn't a satisfactory answer, and the last post was three years ago.
I am using android studio 3.6.2 in windows 10. Every time I try to compile my program I get the error
"The process cannot access the file because it is being used by another process."
Now I know what is causing the error. The R.jar file that was previously compiled cannot be deleted because android studio is locking the file.
It is in a folder \app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug
Now to get around the problem I have been closing down android studio. Then deleting the R.jar, then restarting android studio and then compiling.
This process takes a good few minutes and I have to do it every time. Imagine how long it takes to write a program when you have to do this every time.
When this was asked on stack overflow previously suggestions were to Invalid caches / restart, but that is no quicker than what I did above, and only works once.
Also tried Clean Project, but that has no effect.
I have used many compilers over the years like visual studio, codeblocks etc but this kind of thing never happened before, so why is android studio so bad?
Has anyone found a solution to this problem yet?
[][]
Go to Edit Configurations check that you are not building before each launch. Remove "Build"
I also encountered the same problem in Android Studio 4.x in Windows 10. Simply using "Restart and Invalidate" does not work for me. Sometimes, deleting the build folder will work but I cannot build the project more than once. Here is my solution:
Check Java Runtime Version Used by Gradle and System Default
Having multiple daemons may cause problems as described in documentation from Gradle. To solve this problem,
Open your project in Android Studio
Find the JDK location used in your project (File > Project Structure > SDK Location > JDK Location)
Open a command prompt. Let $ANDROID_JDK be the path you found in Step 2. Type $ANDROID_JDK/bin/java.exe --version to find out the Java version.
Type java.exe --version to find out the default Java version used by the system.
Compare if the version information from Step 3 and Step 4 are the same.
Build with app Configuration
Empty Composable Activity template will create two build configurations.
You should change the build configuration to app as shown in the figure below. This solves my problem.
Proper Launching Procedure
As illustrated in Bilal Aslam's solution, we can edit the build configurations (Run > Edit Configurations). After selecting Compose Preview > Default Preview, you will see Build then Gradle-aware Make in the Before launch panel. Remove Build should be able to solve the problem. The side-effects are unclear.
I am trying to make the a default android application project build and run. This is even less than a hello world.
I am using eclipse neon 3, android 8.0, and my SDK Manager says everything is up to date.
When I create a new Android application project, it immediately has errors, which is crazy to me.
The first error is here: import android.support.v7.app.ActionBarActivity; android.support is squiggled and unrecognized.
The error message is: "ActionBarActivity cannot be resolved to a type".
I have spent all day on here reading about similar problems and tried the following:
-Using the SDK Manger to add "Android Support Library".
This is not shown in my SDK, even when clicking on obsolete.
-RMB Project > Android Tools > Add Support library. This failed:
[2017-06-24 16:07:08 - Android Support Jar not found:] C:\WINDOWS\system32\v4\android-support-v4.jar
So I went and found this file somewhere and put it there. Then it stopped failing but didn't fix my problem.
-Project > Properties > Java Build Path > Add External Jars > android-support-v4.jar. This did nothing.
-Many suggestions have me navigating to C:\Program Files (x86)\Android\android-sdk\extras\android where I am supposed to find all kinds of folders but all I have is m2repository.
Any help would be appreciated, but I would also like to know why this is so difficult. I have been developing in other languages for a while and have never seen a default project be so difficult to get running.
Should I be using a different IDE or something?
Android Support Jar not found:] C:\WINDOWS\system32\v4\android-support-v4.jar
Why is your Android home directory pointed at System32?
Found it and put it there.
That was the wrong solution to the problem. You needed to fix the environment variables for PATH and ANDROID_HOME
have never seen a default project be so difficult to get running.
Because the main development efforts for stability and ease of Android development are focused elsewhere
Should I be using a different IDE or something?
Yes. When you downloaded the SDK, did you skip over all the Android Studio links?
I've recently (this morning) updated a bunch of android plugins in my eclipse environment (so I could switch over to Android Studio), however, I decided to return to Eclipse to finish something up. I had to re-import the actionbarsherlock project (4.2.0 library). After I imported, made sure it was running on Android 4.2 and as a library, I cleaned the actionbarsherlock 'library' project. Which resulted in over 200 'R cannot be resolved to a variable' problem.
I've tried all the usual suspects: couldn't find any errors in the res file, tried cleaning, refreshing, closing eclipse in various different orders.
I'm also noticing a new dependency entitled "Android Private Libraries" -- I am not positive it is new from this update, but it could be.
Other information that might be useful:
- there are no gen files (nothing is being generated)
- I also linked it to my Android Project as a library (set to the same API level)
- I've done separate cleans and a clean at once
Any help would be great, I'm stuck on this one and it's driving me nuts.
You have to check the Android Private Libraries in the java build path of the project:
Resolved by updating the API's as well as the tools and everything else I updated this morning. Very weird situation.
In my case I had the wrong Android target. To solve it:
Right click on your project, then Properties, then click on Android and select the correct Project Build Target.
I had Android 2.3.3 and I changed it to Android 4.2.2
I hope this helps to someone.
This problem was stupid(I mean this situation)... and I was using a stupid way to solve it.
update android API & SDK & anything else you can.
Open your library project's Properties window, go to [Java Build Path], [Order and Export]
Use [Up] [Down] button to make sort sequence like this:
After this, it still shows same error, so you have to re-build this single library project again.
Check top menu, [Project], [Clean...]
Clean that single library project, make it auto re-build.
That's how I solve all my library porject's same problem. (ActionBarSherlock, FacebookSDK, SlidingMenu, ViewPagerIndicator)
Sounds like a stupid solution, but just match this stupid situation.
Google, what the hell are you doing ?
In my case I am running 64 bit Linux (Linux Mint) and I had to install 32 bit libraries using sudo apt-get install ia32-libs
After installing the 32 bit libraries I restarted eclipse and cleaned the ActionBarSherlock library and all is good
Are you using the Android support library?
I had this error because I had a different version of the Android support library jar in ABS vs. the rest of my project. Make sure the support library jars you are using are identical in every project.
Strangely enough, this issue gets fixed when I add old flavors of Android SDK build tools: 18.x and 17.x
(For some reason, I uninstalled some of those)
Please see below. I have a feeling I've got the SDKs configured incorrectly, but I'm not sure how to solve it. I tried Googling for answers but no one had this exact problem.
Do I have the wrong Java version maybe? It seems like the two SDKs might be conflicting with each other.
I made this project via:
Create New Project
Android > Application Module
Defaults and Finish
Edit: See screenshot. I got it working. All I did was create a new project and re-select the Android SDK. I'm still thinking it was because I added too many SDKs/JDKs the first time. I think all you need is the Android SDK and don't need to add the normal Java one too.
I tried what for3st suggested to no avail at first, but i've heard other places that you should use JDK 1.6 for IntelliJ IDEA in other places, so you can do that here. Also, you set the SDK by going 'File'->"Project Structure" -> "Platform SettingS" -> "SDKs"
In the end, I also switched from Android 2.2 to 2.3.3 (api 10) and that got it to work. Don't have a good idea why it didn't work for 2.2, but since I just want a beginner's tutorial, I'm fine with that.
I had exactly the same problem, but the conditions leading up to it are quite unusual.
I downloaded the Android SDK as a zipfile and unextracted it into /opt.
However, the permissions did not allow normal users to enter all directories or execute all files... so when IntelliJ indexed the SDK it only picked up the res jar... and never added the sources to the library path!
Deleting the SDK, fixing the permissions problem in the SDK, and creating a new reference in IntelliJ fixed it.
I had a working Eclipse setup with 3.6.2 and SDK tools from version 11, and it has been building my main project just fine for quite a while.
For a different project, I thought I needed to upgrade my SDK to the latest and greatest - at this point API 14 (ICS 4.0).
I cannot even reconstruct the steps I went through, but what happened was that my project would seem to build, but I would see that it would say that it was skipping a post-compiler step, and at the end I would have no APK.
I also noticed that it updated my .classpath so that the output path was bin/classes instead of .bin.
Along the way I tried updating my Eclipse to the latest version (Indigo 3.7.1) but this didn't help.
I solved the problem eventually with help from this post on the Google Android forum:
http://code.google.com/p/android/issues/detail?id=21031
For me personally the biggest issue seemed to be solved as follows (qutoe from comment 25 in the forum post)
"I seem to solve the problem with .apk files not being built automatically until run/debug is used (comments #10, #11 etc.). Go to Windows -> Preferences -> Android -> Build and uncheck "Skip packaging and dexing until export or launch" then restart Eclipse. Works for me."
But there is other useful material there. Different people with different projects seem to have different problems with this setup.
I still don't understand the change in the classpath, but it doesn't seem to matter.
In addition, I found a discussion of installing the ADT with Eclipse Indigo which was helpful here in Stackoverflow:
Eclipse Indigo - Cannot install Android ADT Plugin
I also found that I guess because of various uninstalls/reinstalls, for some reason it stopped excluding my .svn directories from the sources. This Stackoverflow post was helpful with that:
Why is eclipse trying to copy my .svn folders from src to bin, and how can I make it stop?
Finally: a tip for really and truly uninstalling Eclipse - everybody says there is no uninstall, and there isn't, but there is a directory that Eclipse leaves in your home directory (in windows 7 under c:\users\) called .eclipse -
Zap it if you really want to start fresh.
In addition, for less extreme measures, there is Project->Clean inside Eclipse, and you can invoke eclipse with "eclipse -clean" for additional cleansing effects. No idea what, but various helpful people along the way suggested trying that to solve problems.
Ah yes - when I first installed Indigo and tried to build, I got a warning that my Java Compiler Compliance level was not up to snuff, which was simply not true - I have only Java 1.6 installed on my machine.
See this post for somebody who had similar experience:
http://marakana.com/forums/android/general/374.html
For me, what worked was simply going to Project, Properties, Java Compiler, then click on Configure Workspace Settings, and click on Ok in the dialog. Didn't need to actually change anything. Just showed it that everything was ok!
Eventually I indeed did clean out my Eclipse and Android installations (including the aforementioned .eclipse directory, and there's also an .android directory in your home directory which you may want to erase if uninstalling the Android SDK Tools doesn't do that - this actually is uninstallable). Installed everything from scratch and then used the additional information provided above and now it's building my APK.
I hope this saves somebody the hours I spent getting my build back in shape.