unable to resolve static method: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable - android

ok...this is driving me nuts.
I've added and re-added the Google Play Services Lib multiple times (with and without copying to workspace) but when I try adding it as a reference to my project, it always shows as a red X next to it when I go back to the project properties as in this guy's screen captures:
Adding a reference to a library project
No errors print to the console. Anyone know why this would show up as a red X or how to debug this? I've added Android Bar Sherlock the same way w/o issues. It's just the Google Play Services library that's driving me up the wall :-P
I also tried creating a new project and following this quickstart and have the same issue. It's almost like my Eclipse is broken in some way but it's a fresh install :-P
https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw
I can work around the compile time errors by adding the library in the project properties java build path, but this should not be the way to fix it. And if I try running the app on my SGS3 this way, it crashes w/ the error in the title. I can add the play library jar to my libraries, but then it crashes with an error about looking having problems looking up r$styled so that doesn't work either :-P

Figured it out finally. Got bit by this:
unable to resolve static method: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable
https://code.google.com/p/android/issues/detail?id=27199
Everything runs properly now.
Damned annoying bug. I remember being bit by it years ago and it's still not fixed :-P

Related

Warning when building app: "Expected stack map table for method with non-linear control flow."

I have a project on which I worked last year. Recently I started working on it again but wanted to update everything that was possible. I managed to resolve basically all problems except this one. I can't find anything online about this warning. I get it when I build the project. I tried downloading and using the latest tapjoy jar but it still appears. In the warning there is a path to a cache folder so I tried deleting it but id didn't change anything; maybe I'm getting this warning because those folders are missing?
The full warning is like this:
AGPBI: {"kind":"warning","text":"Expected stack map table for method with non-linear control flow.","sources":[{"file":"C:\\Users\\black\\.gradle\\caches\\transforms-3\\91514d5ad9a3a762574d6c5e2880beba\\transformed\\jetified-tapjoyconnectlibrary.jar"}],"tool":"D8"}
The problem is that i have around 200 lines of this warning in console and I would like to solve them.
Has anyone seen this warning before and knows how to fix it? Obviously any help is much appreciated.
The missing folder should have nothing to do with this warning. I had this problem in the process of writing custom gradle plug-ins. It seems that ClassWriter or ClassVisitor in ASM did not implement any method, there will be this warning, but that does not affect normal functionality. You can check that your project has used those gradle plug-ins, perhaps these plug-ins are caused by the update of the problem.

Android libGDX: Eclipse crash when using google-play-services_lib

I'm learning how to make games in libGDX, and I'm trying to add ads to my game.
I'm following this tutorial:
https://www.youtube.com/watch?v=cwAN4LMXo58
(I'm using Eclipse instead of Android Studio).
I got stuck at 9:35 of the tutorial; I've copied all the code and everything seems to look good; but when I try to run the code, nothing starts; Eclipse just keeps loading until the following error pops up:
Unable to execute dex: GC overhead limit exceeded
GC overhead limit exceeded
It seems to be the same problem as this guy had:
Importing "google-play-services_lib" into Eclipse crashes libgdx project
But I followed all the suggested steps and Eclipse still crashes... (I seem to have too little reputation to comment on that post).
Eclipse didn't crash before, when I didn't select google-play-services_lib in Properties - Android (after right-clicking the android project), but had it selected in Properties - Java Build Path ; but then there was a different problem (which I've partly forgotten), I believe the class AdView couldn't be found or something (sorry for not being to able to be specific).
I'm using Eclipse Luna. I've tried to make a new project just to try everything a second time; same problem.
Please tell me if it would help to post other information! :)
This issue is related to your VM options which you can change in your Eclipse.ini file. I don't know your default values but if you increase -Xms and Xmx limits, your problem will be fixed.
...
-Xms1024m
-Xmx1024m
...

Adding google maps library to existing project creates confusing error

I am building an Android app that I want to open google maps with the click of a button. I want the app to find the current location of the user and give them directions to a predefined address. I started building the application before I realized there were special steps that you have to take to include this functionality. To add this feature to my project I followed the directions on these two sites:
https://developer.android.com/google/play-services/setup.html
https://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject
The problem is on the second site, when i added the library to my already existing project it caused all of my code that has findViewById(R.id.whatever) or setContentView(R.layout.whatever) to become errors. It is now telling me that i need to import the class R. If I do that it then gives me error messages on the names of all my xml files.
For example in my MainActivity it is telling me that i should change setContentView(R.layout.activity_main) to setContentView(R.layout.activity_list_item) and does this for all references to my xml files for the entire project.
I tried going back and removing the google play services library from the project and starting over but when I removed it the errors still persists. I also tried using the "fix project setup" option in Eclipse but it didn't fix the problem.
I'm wondering if anyone here has experienced this problem before? If so, how can I fix it? The application had no errors before I tried to include the google play services library. I am new to Android development so a lot of the information I have found has been either confusing to understand or doesn't seem to include enough details for me to figure it out. Thanks for your help!
Look at your imports, and check if you are importing the correct R.java from your application package, not from the android package.
Check also if your XMLs don't contain errors, otherwise R.java won't be generated.
In my case android-maps-library had to errors in two files (I have forgotten their names), I edited the two files removing errors my self. And finally I was able to used it quite nice.
i think you have correct yout Project build target, and this how:
right click on your project folder in the package explorer->propreties->Android
then porject build target and choose you Android target (Android x.xx)
but before that you need to remove import android.R;

unable to instantiate application - ClassNotFoundException

EDIT: This problem has not already been resolved in the other suggested SO question
I had a fully working app on the market for over a year, with very few crash reports. Then recently I changed my app into a library, so that it could be included within multiple different "wrapper" projects. This was so that I could easily make different version - free, paid, non-google markets, with/without in-app purchasing etc etc.
The new "library+wrapper" app appeared to work fine. I could run it multiple times, without error. But then a day later (when presumably the OS had closed some or all of the app's activities) I tried to run it and it reported
Unable to instantiate application com.mycompany.mygamelibrary.MyGameApplicationClass: java.lang.ClassNotFoundException: com.mycompany.mygamelibrary.MyGameApplicationClass
The class it failed to find is the first class that runs when the program starts up, MyGameApplicationClass - which extends Application. This class is part of the library.
I suspect something goofy in one of the two manifest files.
The manifest of the wrapper project contains the lines...
<application android:icon="#drawable/mygame_icon"
android:screenOrientation="portrait" android:label="My Game Name"
android:name="com.mycompany.mygamelibrary.MyGameApplicationClass">
Any ideas what could have gone wrong?
EDIT: The library was referenced "the correct way" as defined by yorkw's answer to this SO question.
EDIT: I can not repeat the crash at the moment :-( I don't know what it is the OS does when the app is not used for a day or two.
There are two possibilities. Either you, like me, have a spelling error in your manifest file. Have a co-worker or friend read it to make sure the name is correct. Or you have not referenced the project correctly.
The official document describes how to properly link projects in its documentation.
Why it would first seem to work and later stop working is a bit of a mystery. However, I guess that the VM might still have had the necessary references ready to resolve the classes in the library just fine. A restart of the VM removed all those references and trying to resolve them was unsuccessful.
Update: Regarding the edits in the OP: As you confirm that you have correctly referenced the other project, you can check if the project is included in APK, just to be sure. You can rename and open an APK as any other archive (.rar works fine for me). Sometimes, it happened to me, the project is not correctly included in the APK. A cleaning of your workspace usually remedies the problem and so could a restart of your IDE depending on what you are using. To manually conduct a clean in Eclipse for example, use Project->Clean... or try Android Tools->Fix Project Properties by right-clicking on your project.
As you seem to also have fixed the problem by restarting your device, it could be that the libraries were linked incorrectly. A problem that I have never seen myself but as a very common quote says: "Have you tried turning it off and on again?".
For Android Studio:
Build --> Clean Project
Fixed issue.
Have you tried to make a new subclass of MyGameApplicationClass in your 'main' project and set it in the manifest as Application class?
I had a slew of bugs with Android Studio 3.0 Canary 4 and the way I fixed them was by editing the AndroidManifest.xml by adding in some jibberish to the application name. Then, I clicked build. Obviously, a whole mess of new error messages appeared. I changed the name back to what it should be, built the app, and it just ran.
Sometimes, I just don't know...
EDIT: Just ran into this issue on Android Studio 3.0 Canary 4 on my laptop when switching over. I again went through the same process of changing AndroidManifest.xml file to contain a typo, building, and changing back. That didn't work.
I then noticed that instant run was still enabled. Going into settings (by clicking command + , (comma key)) and typing "instant run", I was able to disable instant run, built the app, and the error of class not found went away.
Summary of Steps to Fix [FOR ME]
Invalidate cache / restart
Clean the project
Manually delete the build folder (need to be in project view for this one)
Make an intentionally errant edit to your AndroidManifest.xml file, build the app, observe the errors, remove the errant edit and build again
Disable instant run
Again, I don't mean to insinuate that this will fix everyone's error, but I have now used some combination of these steps on two different machines (MacOS Sierra) and it has been resolved for me. Hope it helps.
In my case, application id and package were mismatched. This should be same as presented in following images...
AndroidManifest.xml
app/build.gradle
In this case you can see, applicationId and package both are same that is com.mycompany.mygamelibrary
May be its a Build Path Configuration problem.I did the following to solve the issue.
1.Right click on your project and go to Java Build Path.
2.Click on Order and Export tab.
3.Check Android Private Libraries and other 3rd part libraries if you have added.
4.Press ok and clean the project.
I hope it will solve the issue.
Once I had the same error message, but maybe the cause isn't the same.
I did a code and worked for a while, then I wanted to improve it and got the same error and I couldn't run it.
I could fix the problem with
the correct Build Path order (as I can see you've already did this)
I check on the Order and Export tab the android-suppor-v4.jar
and the key was the Android SDK Managert->Upgrade everything and (next) Eclipse->Help->Check for updates.
After I upgraded to the latest android plugin and SDK my app compiled and ran again.
I hope this will help you!
I'm not very sure about this but it might be that your system's debug.keystore license validity has expired as it is valid for only 365 days. You just need to delete the debug.keystore from your computer. The debug.keystore will be generated automatically by Eclipse when you compile your Android App.
Same message seen ... this time it turned out to be different output folders for MyApp/gen and MyApp/src in the Build Path (caused by Maven integration).
Unchecking "Allow output folders for source folders" solved the problem.
I had this issue in an Android application that needed an Application class which was created in wrong path inside the Android Studio project. When I moved the class file to the correct package, it was fixed.
This all Process work for me to solve application class Exception.
Step 1: Open Run(window+R) Search -> Prefetch Remove all file (Some file not Delete)
Step 2: Open Run(window+R) Search -> %temp% Remove all file (Some File not Delete)
Step 3: Open Android Studio -> Build -> Clean Project
OR
Select File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio toolbar.
OR
Close and reopen Android project.
OR
Restart System
I ran into this issue several times and both times it seemed to be caused by some instant run feature.
In my case, deleting the application from the device and then installing it from Android Studio again resolved the issue.
I ran into this problem today. The project runs well for over a year but today it reports this issue, and cannot debug on my testing device.
I fixed it by updating to latest gradle version. Hope this can solve your problem.

Android: Conversion to dalvik format failed with error 1 ADT 2.1

This error during the export process is driving me crazy. It appeared after updating the ADT and adding ActionBarSherlock library, not sure which one is causing the trouble. I've already removed all the libraries and added them again, I've created a new project and copied the code over, didn't work either.
What other things can I try? (And don't tell me clean the project I've done that thousends of times)
This really sounds as though it can't be true but it works for me, so hopefully it also works for you if the problem isn't related to library linking stuff...
When you are in Eclipse, just turn off automatic build and then export without getting this error.

Categories

Resources