NotificationManagerCompat Can't be resolved - Android Wear - java

I'm sure I've just missed something obvious, but I'm at a loss of where to look to solve this.
I'm trying to get started with android wear, and am following the tutorial on this page.
However I can't find any information about which libraries I need to include or where to get them from.
I'm using eclipse and have used the Android SDK manager to download the Android Wear System Image (although I have a G-Watch to test it on) and all the 4.4W stuff, and I've set the project to build against 4.4W but I still get the following error
The import android.support.v4.app.NotificationManagerCompat cannot be resolved
The import android.support.v4.app.NotificationCompat.WearableExtender cannot be resolved
I have the android-support-v4.jar included and android.support.v4.app.NotificationCompat is found OK, but I can't see anywhere in the android wear docs that it says I can get this library and it's driving me nuts.
If someone could point me in the right direction that would be great.
Thanks

There is no android.support.v4.app.NotificationManagerCompat in the support library.
There is in the current one. Examining my android-support-v4.jar shows this class. Make sure that you have the latest version of this JAR downloaded to your machine (from the SDK Manager) and in your project (e.g., copied to libs/ from $SDK/extras/android/support/v4/, where $SDK is wherever your Android SDK is installed).

Related

AndroidManifest.xml and Bluetooth Chat, in Android Studio

A gentleman was kind enough to pass me a link of a repository with bluetooth functionality. I imported it from GitHub. I tried then copying it, but noticed eventually that Android Studio built and organized a different style of directory than that from the github repository. So I deleted the entire directory, and just pasted that of the github depository in.
However, the repository version suffers from the fact that the classes say "Java file outside of source root". Moreover, when I tried to import it, it generates the error "The project is using an incompatible version (AGP 7.3.0) of the Android Gradle plugin. Latest supported version is AGP 7.2.2". I read online I could just update Android Studio instead of downgrade Gradle. When I do the most recent update (I think), Android Studio tells me that the project doesn't use the Gradle build system.
Also, AndroidManifest.xml says that it can't resolve certain activities, such as "MainActivity", which does exist. I think AndroidManifest.xml is in the root folder as it should be.
Any idea what is wrong with my program? At this point, this is just copy-and-pasted from the github Bluetooth Chat program. Is that outdated, etc?
I have spent hours trying to troubleshoot this. Perhaps there is someone with some experience in it.

Android APK invalid? Didn't find class "AndroidLauncher" on path: DexPathList

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.

Errors in android.app.Activity.java

After setting up Android Studio, I tried to find out how few of the methods work but I can see that Activity class have got a lot of errors.
For example:
// Gives: cannot resolve symbol 'CallSuper'
android.annotation.CallSuper();
// Gives: cannot resolve method 'trackActivity(android.app.Activity)'
private final Object mInstanceTracker = StrictMode.trackActivity(this);
// Gives: cannot resolve symbol 'MainThread'
#MainThread
// **312 errors in android.app.Activity, 579 in android.view.View**
My application works fine though. How can i make those errors disappear and be able to see documentation of structures that cannot be resolved now?
Details on my Android Studio 2.1.3 configuration
Installed in Standalone SDK Manager:
Android SDK Tools
Android SDK Platform-tools
Android SDK Build-tools
SDK Platform and Sources for API 24
SDK Platform, Documentation, Google APIs and sources for API 23
Extras: Android Support Repository, Google Repository and Google USB Driver
Being precise, those aren't errors in the source code for Activity/View it's just that :
Your IDE can't find the class android.annotation.CallSuper in it's classpath.
It cannot resolve method trackActivity in class android.app.Activity.
This is because the SDK is subset of the actual Android platform. The SDK shipped to the developers a.k.a Public API utilizes a lot of platform features a.k.a. Internal APIs, hence you can't find them in your SDK 24 classpath.
So why are all these portions hidden from developers?
It's kept hidden from developers because most of its implementation varies from device to device, plus they wouldn't be required in 99.99% cases (metaphorical figure not actual stats). You might want to have a look here.
add in your build.gradle file:
dependencies {
compile 'com.android.support:support-annotations:22.2.0'
}
This simply means those classes arent on the classpath. When you run an app on a mobile phone or in the emulator the platform make sure the classes are all present.
... i tried to find out how few of the methods work
The easy way to look at Android source code is to just browse it online. For example here is the Activity class.
If you install the "Android SDK Search" plugin for Chrome, it will automatically add source links to the online Javadoc.
How can i make those errors disappear and be able to see documentation of structures that cannot be resolved now?
The only way to view live code without compile errors is to download and build the entire Android Open Source Project.

How do I setup the Facebook SDK in Android Studio 1.0.0? Getting SDK Location not found error

I tried importing the sample, but I got an error saying
"Error:(1, 0) SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable."
I then tried importing the Facebook SDK module into a blank activity. I can't seem to get it working. If not the error above, it has a strange gradle error. I spent hours trying to fix it, but no luck.
Please note that I'm very new to Android and I'm not even sure how to handle the gradle things. Any advice would be helpful.
Android studio is not very fast in my opinion. Im using Eclipse which is better i think. I never did use android studio much but lets see if this works it is used in Eclipse.
Right click on your libs. Add the facebook sdk. Right click on the facebook sdk. Then build path. Im not sure if this qill work for Android atudio since its made by the same company who made IntelliJ. JetBrains.

Eclipse Incorrectly Claiming I have old Rev of Android SDK

Just to preface this I have searched high and low on the internet trying to find an answer to this problem and have yet to find one, there have been people with similar problems as me but not quite the same.
I have been trying to set up Eclipse with the Android SDK. I installed Eclipse (Classic) first and edited the .ini file to find the correct javaw.exe file. I tested eclipse and it was working fine. Then I downloaded the android sdk bundle extracted it and used the SDK manager to download the necessary SDK tools (Rev. 21) and the Android 2.33 API. After finishing that, I went back into Eclipse, clicked "Install New Software" and in the "Work With" field typed
"https://dl-ssl.google.com/android/eclipse/". From there I installed the Developer Tools and NDK plugins and then when finished restarted Eclipse.
Now when I start Eclipse I get the following error
"This version of ADT requires Android SDK Tools revision 21.0.0 rc9 or above.
Current version is 11.0.0
Please update your SDK Tools to latest version"
I know for a fact I have rev 21, it said it when I downloaded it and when I try to go in and update anything whether it be through Eclipse or through the manager it says there are no updates available. I know I have the latest of both the SDK and ADT and I have also tried using the version of eclipse that came with the sdk but that gives me the same issue.
The only other things which seem to set off red flags to me are
1. When the program loads it shows the following message in the console
"[2012-12-01 18:31:48 - Dex Loader] SecurityException: Unable to find field for dex.jar"
2. When I try and open the SDK manager through eclipse it never opens and the console displays the following message
"[2012-12-01 18:37:07 - SDK Manager] [SDK Manager] Error: Expected verb after global parameters but found 'sdk' instead."
I don't know if either of those two have anything to do with what is causing this issue but I hope someone knows what is going on. If someone could help me figure this out I would greatly appreciate it, thank you in advance.
(For reference sake, I have been following the instalation instructions in this tutorial
http://youtu.be/31cxmLN09ss)
When in the SDK Package Manager, try choosing Packages menu -> Reload. Then you should see Android SDK Tools rev21 available and ready to be updated.
i had the same problem. it occurred because once when I was trying to install the adt plugin few months earlier, the location had been saved. I oversaw the old folder location, mistook it for the current updated one and bam! that was all the reason. try to check back the location for tools folder specified.
As follow up to my previous suggestion, better solution is to modify your sdk location in Windows->Preferences->Android to where you install your ADT bundle. For example, if you install your ADT Bundle under C:\Tools\adt-bundle-windows-x86-20130219, enter C:\Tools\adt-bundle-windows-x86-20130219\sdk.
Doing this also fixes other issue with "Android SDK Manager" not launching from within Eclipse discussed on another thread.
I resolved the issue with Eclipse reporting that I have an older sdk even though I have the latest installed by copying the correct sdk version under "C:\Program Files\Android\android-sdk". First save existing "C:\Program Files\Android\android-sdk\sdk" to say "C:\Program Files\Android\android-sdk\sdk_old", in case you need to revert.
This (above) is sound advice: however I went in eclipse and redefined the android sdk location which apparently was on a different android folder for whatever reason which had outdated files in it and I believe now the situation is fixed I tried it and it worked for me too. Thanks.

Categories