After upgrading from the last Android Studio 2.0 preview to Preview 5 I'm having trouble with the imports from the android.support.wearable
package.
Both the main app and Wear app builds and run just fine, but the editor in Android Studio complains that it can't resolve the these imports
import android.support.wearable.activity.WearableActivity;
import android.support.wearable.view.CircledImageView;
import android.support.wearable.view.WearableListView;
In the Wear module's build.gradle I have the following dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':common')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.google.android.support:wearable:1.3.0'
provided 'com.google.android.wearable:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
}
As I understand from http://developer.android.com/training/wearables/apps/always-on.html#EnableAmbient this should work when using the provided statement. And it has worked well until the Android Studio upgrade. Am I missing something?
This isn't just a problem with the Wear library, it's general for what seems to be any external dependency. (Topic originally was Unable to resolve package android.support.wearable in Android Studio 2.0 Preview 5.)
It seems like the problem can occur at any time, but in practice it happens mostly whenever I do lotsa changes in a class (maybe changes to the imports?). Just now it suddenly was unable to resolve the imports of Play Services and Facebook ads (while still working for other dependencies).
I accidentally found a workaround of the problem: If I open and build the project in Android Studio 1.5 which I also have installed, all the imports are fixed. Going back to Android Studio 2.0 I can continue programming without the imports becoming unresolvable for a long while.
For anyone googling the problem, the error message in Android Studio is the usual Cannot resolve symbol '[package]'.
I had this problem even before with AS 1.5, the easiest way for me to fix it was to use the Terminal inside Android Studio and execute:
./gradlew assembleDebug
This will work if you're not using flavors if not just use the name of the flavor, for e.g:
./gradlew assembleFlavorNameDebug
that should work too as a workaround without leaving your current instance of AS, and then the compiler recognizes your imports if everything is setup properly.
For more references please look: http://tools.android.com/build/gradleplugin https://stackoverflow.com/a/21307568/799162
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With