I am getting an error on an import statement that I am using in order to try and implement Play Games with my app.
-The import com.google.android.gms.games.GamesClient cannot be resolved
I have BaseGameUtils referecncing google-play-services_lib, and my project references BaseGameUtils as a library.
It's my understanding that GameClient was to have been deprecated as of February 7, 2014 but when looking at Google's sample code (e.g. ButtonClicker) it still uses this import and some of the method calls from the import.
I got the code I am using from Google's GitHub sample app repository for the ButtonClicker2000, some of that code has been recycled and used in the program I'm having errors with as well.
This is all the info I can think to provide, if anything more would help please let me know.
I was struggling with the ButtonClicker2000 example for a couple days and I was having the same problem as yours.
I think the problem in the sample code is having some lines being not updated. If you look at that page, you can easily see that the updated versions of those lines are lying there. However the codes in GitHub page are not updated completely.
Because GamesClient class is removed permanently, those statements
GamesClient.EXTRA_PLAYERS
GamesClient.EXTRA_MIN_AUTOMATCH_PLAYERS
GamesClient.EXTRA_MAX_AUTOMATCH_PLAYERS
GamesClient.EXTRA_INVITATION
GamesClient.STATUS_OK
must be replaced with
Games.EXTRA_PLAYERS_IDS
Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS
Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS
Multiplayer.EXTRA_INVITATION
GamesStatusCodes.STATUS_OK
Also that line can be removed:
import com.google.android.gms.games.GamesClient;
There is no need for importing GoogleApiClient because it is already imported in GameHelper.java.
After changing these lines manually and importing Multiplayer and GamesStatusCodes classes, I was successful to compile the code. I hope that solves your problem as well.
Related
I am using these two libraries in my project:
https://github.com/HemendraGangwar/VideoTrimmingLikeWhatsapp
https://github.com/fishwjy/VideoCompressor
Both libraries are imported locally to my project (i.e. copied them and added them to the project)
Both libraries work fine when used separately, but when I use them together I get some errors of type Program type already present which I solved by deleting the file isoparser-1.0.6.jar from the second library, because I noticed that the two libraries use the same library 'com.googlecode.mp4parser:isoparser' but with different versions: 1.1.21 for the first one and 1.0.6 for the second one.
When using only the old library, I get this code:
error: cannot find symbol class FileDataSourceViaHeapImpl
It is working now, but the problem the output video (after compression) does not have sound on it. How can I solve this?
Here is the code I am using for compressing the video (after trimming):
VideoController.getInstance().convertVideo(tmpFile.toString(), dstFile.toString(),
VideoController.COMPRESS_QUALITY_MEDIUM, null);
EDIT1
Summering the scenarios here with the same video:
VideoTrimmingLikeWhatsapp with verion 1.1.21 => works
VideoTrimmingLikeWhatsapp with verion 1.0.6 => does not works (compile error of missing classes)
VideoCompressor with 1.1.21 => does not work (no sound)
VideoCompressor with 1.0.6 => work
I tried a lot of things, and I am loosing tracks here. I also tried using SiliCompressor which seems also using version 1.0.6 of mp4isoparser, and the same problem is happening, output video has no sound. I posted an issue here a few days ago, but I don't think they will address this any time soon.
I also submitted here.
I tried downloading the mp4parser version 1.1.21 from here, and tried to import it locally so I can change the package names, but I couldn't because it using Maven not Gradle. The old version is a jar file, and I need to decompile it so I can mess with it. Can I do that?
I also tried using ffmpeg libraries, but all of them work very slowly compared to mp4isoparser
EDIT 2
The author of SiliCompressor has replied to the here I opened, he says that the problem should be solved by now. For the moment I am unable to verify it, as I no longer work on that project. If any one can confirm it, just tell me to add the answer to this topic.
This combination worked for me:
implementation 'com.iceteck.silicompressorr:silicompressor:2.2.3'
implementation ('com.googlecode.mp4parser:isoparser:1.0.6') {
exclude group: 'org.aspectj', module: 'aspectjrt'
}
Credit to: https://github.com/AndreyAsadchy
https://github.com/Tourenathan-G5organisation/SiliCompressor/issues/141#issuecomment-625308490
If the problem is really caused by the libraries version it is going to be tough to solve.
First I'd double check that. You said you tested the libs separately and that they worked, but, have you tried using the output of 'VideoTrimmingLikeWhatsapp' as input of 'VideoCompressor'?
I'm suspecting that 'VideoCompressor' does weird things with audio in some circumstances, somebody in this issues says there is no audio:
https://github.com/fishwjy/VideoCompressor/issues/1
If you get a video without sound using 'VideoCompressor' with his own version of 'isoparser' you can discard libraries version as the source of the problem.
Then, I think, you can: replace 'VideoCompressor': it seems to rely on Android libraries to perform the compression, you may implement that yourself, or you could find another library for doing the job. Or you can fix 'VideoCompressor': you could report the problem to the author or you could try to fix it yourself.
If you confirm the problem is the versions conflict: Then I can think several options, but none of them is easy:
You can try playing with classloaders and force each library to use their correct version of 'isoparser'. This alone can be difficult to do, besides that it can be very problematic in Android.
You can patch one version of isoparser, renaming package names (for example to com.googlecode.mp4parser_old ) so two versions of them can coexist, you should also patch the client library for using the new package names. This is very ugly but seems doable.
You can try to update 'VideoCompressor' to be compatible with isoparser-1.1.21. You could also ask the author to do it.
Again, you could replace 'VideoCompressor' (or may be 'VideoTrimmingLikeWhatsapp')
I'm aware this is not the definitive answer but I hope it helps you a little.
It's too late but i send this solution to be useful for others.
Yes, the problem is about version conflicts between the two libraries.
Solution:
Don't touch video compressor library at all.
Downgrade the "isoparser" dependency of video trimmer to the same version (1.0.6) with video compressor library dependency "isoparser".
Remove the following line from TrimVideoUtils.java file:
import com.googlecode.mp4parser.FileDataSourceViaHeapImpl;
Then change the following line:
Movie movie = MovieCreator.build(new FileDataSourceViaHeapImpl(src.getAbsolutePath()));
To
Movie movie = MovieCreator.build(src.getAbsolutePath());
It's done.
NOTE: Be careful about large files. Because this solution doesn't use memory mapping.
I am trying to find the dependency for this import statement that I obtained from another program but unsuccessful so far.
import com.facebook.share.internal.ShareConstants;
That would be the Facebook android SDK. If you scroll a bit in the page below, you'll find instructions on how to use it in your project. You might want to inform yourself on the version of the SDK which the program was originally using, though, to avoid compatibility issues.
https://github.com/facebook/facebook-android-sdk
I have been trying for the past day to get at least google's sample code working. Every single of their sample code have dependencies issues or errors within the code (even they have stated in quick start thats a copy/pasta code to test the api - never works). I have installed all of the dependencies, I pointed the jar file to the missing imports, but no success in that..
Can anyone tell me where is the problem when my jar is in dependencies but it never finds it?
I wish they had a normal way of taking json data - via url, but they disabled this.
I have two example imports.
import android.os.MessageQueue;
import android.os.PerformanceCollector;
Both files, after tracking them down, is in Android/Sdk/sources/android-19/android/os. MessageQueue.java and PerformanceCollector.java.
In my Android Studio->Project Structure->SDK Location, Android/Sdk is marked.
MessageQueue works. PerformanceCollector gives "Cannot resolve symbol 'PerformanceCollector'".
Cleaning/invalidating caches/restarting/reimporting did not work. Can someone suggest what might be the cause of this? It would be appreciated.
I don't know why I didn't find the PerformanceCollector class in Android Documentation
but you can use this code. Just create a new class in your application
PerformceCollector Source code
pskink was correct. The reason I was seeing an error was because the class "PerformanceCollector" was hidden by {#hide}. However, having done further research from there I have found that this isn't an issue at all.
How can Android project compile when imported class is missing in SDK?
- From reading the answer to this question, I have found that the error will not appear when running the application at runtime, so the fatal error I am getting has nothing to do with the issue I asked this question about. It was unrelated, as I now know what the real cause was.
So, pskink answered with a comment and not a proper answer, so I can't mark him/her as being correct. So, this will do. Thank you all who've read my question and so on.
I've been trying to get a basic project from the samples from Google running for a few hours now. I've followed every step so far and not really changed anything from what it's told me but after importing all the libraries and pasting the default code the program is complaining.
Description Resource Path Location Type
AccessTokenResponse cannot be resolved to a type MainActivity.java line 63 Java Problem
Some others are reported missing like. GoogleAccessProtectedResource, GoogleAuthorizationCodeGrant, GoogleAuthorizationRequestUrl.
From the default code of
// Step 1: Authorize -->
String authorizationUrl = new GoogleAuthorizationRequestUrl(clientId, redirectUrl, scope)
.build();
The fact this is not working is obviously leading to assume it's something to do with oauth2.
I'm pretty new to fiddling around with Android and Java, but after reading around I did manually import the libraries via right clicking > properties > java build path.
I've imported all the ones it said to import and cannot understand why it is erroring on practically the first step.
This is what I've imported.
Libraries:
All I want to do is view a public calendar in the Android Application. Been so much bother to get this API working
The code that I'm looking at for setting this up is found here
Thanks!
Hi I am facing the same issue with other classes of the client library, particularly with the GoogleAccessProtectedResource class.
From what I found out GoogleAuthorizationRequestUrl is not being used any more in the latest versions instead of that you should try to use GoogleAuthorizationCodeRequestUrl which is found in the following package
com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl;