Is the Material Design NavigationView not yet compatible with AndroidX? - android

I just converted my App from the support library to AndroidX. Everything compiles now and the App starts successfully. However one of my activities uses com.google.android.material.navigation.NavigationView which seems to still depend on the old support library. Specifically I see dependencies on the following classes if I look into the code of NavigationView:
import android.support.annotation.DimenRes;
import android.support.annotation.Dimension;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.annotation.StyleRes;
import com.google.android.material.internal.NavigationMenu;
import com.google.android.material.internal.NavigationMenuPresenter;
import com.google.android.material.internal.ScrimInsetsFrameLayout;
import com.google.android.material.internal.ThemeEnforcement;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.AbsSavedState;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.WindowInsetsCompat;
import android.support.v7.content.res.AppCompatResources;
import android.support.v7.view.SupportMenuInflater;
import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.view.menu.MenuItemImpl;
import android.support.v7.widget.TintTypedArray;
In my apps build gradle I depend on:
implementation "androidx.appcompat:appcompat:1.0.2"
implementation "com.google.android.material:material:1.1.0-alpha01"
Since I am using the new dependency to the material design library (which is the one also given my the AndroidX migration guide), I was expecting all the classes having the correct dependencies. Am I wrong here? Is this not ready yet? Does someone have any additional insights I am missing?

I was also facing the same issue, for me adding following dependency in gradle worked.
implementation 'com.google.android.material:material:1.0.0'
EDIT latest stable version available is:
implementation 'com.google.android.material:material:1.3.0'

Related

How to know which Support Library version my Android app is using?

In my gradle.properties I have this:
android.useAndroidX=true
When I Make Project, I get BUILD SUCCESSFUL. From Android Studio, I go to Refactor > Migrate to AndroidX... I am getting 15 references in 9 files to be changed:
Reading https://medium.com/androiddevelopers/migrating-to-androidx-tip-tricks-and-guidance-88d5de238876, I see that the step 1 of the recommended approach to migrate is to Update to Support Library version 28. In order to do that, I want to know what Support Library version the code of my app is at. Where can I see that? In some of my .java files I have found the following:
import android.support.annotation.NonNull;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.content.ContextCompat;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.multidex.MultiDex;
In my app\build.gradle I have this: implementation 'com.android.support:multidex:1.0.3'.
Do any of the lines above reveals or helps to reveal the Support Library version that the code of my app is at? Thank you.
What it means is that they suggest upgrading all of the possible support libraries to 28.0.
Those are basically anything that starts with com.android.support:
e.g.:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
The recommendation there is so the migration in the AS will have to do minimal guessing on how to migrate it.
So to stricly answer your question, the version you use is the version you have in gradle.files.

import android.support.v7.app.AppCompatActivity not found

I have recently migrate one project in androidx .This project working fine . Now when i am opening other project in android studio i am found in all other project i am getting error
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
these all package not found i have not changed any thing other project . Why android support libraries not workig with other project. Please help me how can i run android support lib again this android studio .I have done already invalide chache and restart and also clean project but no luck
You need to use androidX dependencies like this:
import com.google.android.material.navigation.NavigationView;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
Make sure you have updated your app.gradle too
api 'androidx.appcompat:appcompat:1.1.0-rc01'
api 'com.google.android.material:material:1.1.0-alpha08'
You also need to add the following to gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Once you update your gradles and delete the old dependencies Android Studio should find the new ones.
Add the support library to the dependency section.
implementation 'com.android.support:design:28.0.0'

Android studio doesnt recognize some libraries.(import statements)

Android studio does not recognize some import statements like
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManager;
But it recognizes some import statements like
import android.text.TextUtils;
import android.view.KeyEvent;
How can I fix it?
Ensure you have added the necessary dependency in your gradle file and have done a gradle sync to download the required packages
compile 'org.igniterealtime.smack:smack-android:4.1.8'
compile 'org.igniterealtime.smack:smack-tcp:4.1.8'
This worked for me

cannor resolve symbol "baidu" android studio

import com.baidu.android.pushservice.PushConstants;
import com.baidu.android.pushservice.PushManager;
I am unable to import the above libraries into my android application.
What dependencies should I add in the build.gradle in order to import them?

Error package `com.google.android.gms...` doesn't exist

I am new to Android development. I am learning to use Parse.com backend service and get stuck early on.
I am following tutorial to create application that uses Google Maps Android API v2. What I've done :
download sample
project from parse
Import AnyWall-android\Anywall folder from downloaded project to Android Studio
Rebuild project
Then I get a bunch of errors here :
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap.CancelableCallback;
import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
common, location, and maps highlighted red. The question is how to resolve these errors?
I appreciate any kind of help or direction (What should I check? Is it about missing library? If it is, what library should I add and where to get it?)
Can't find the class com.google.android.gms.location.LocationClient (android)
There is some problem with the last GPS lib. You have to use an older version than the latest(6.+). Try with an older version. I didn't see anything inside the doc deprecated or missing about the LocationClient.class...
compile 'com.google.android.gms:play-services:5.+'
I think the best solution is, add compile API on your Gradle. services-location has this method.
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
if you wish to include other services, please refer here:
https://developers.google.com/android/guides/setup (scroll down)
Google Play Services is now modular, you can select the packages you want from it.
To get analytics add:
compile 'com.google.android.gms:play-services-analytics:7.3.0'
to you build.gradle's dependencies section
P.S
replace 7.3.0 with new version as they arrive, or replace with "+" to always get the latest
Android Studio is complaining that it can't find the Play Services library.
Follow the steps here to ensure Google Play Services SDK is installed (specifically, make sure 'Google Repository' is installed along with 'Google Play Services'): http://developer.android.com/google/play-services/setup.html#Install
Then, make sure the following is added to the dependencies{} block in your build.gradle:
compile 'com.google.android.gms:play-services:+'
Clean and rebuild.
Add this line you build.gradle in Gradle Scripts folder
dependencies {
compile 'com.google.android.gms:play-services:11.2.0'
}
with this i solved this issue.
Previous answers were correct.
But in gradle:3.0 the compile configuration is now deprecated and should be replaced by implementation or api.
Check out more information in the documentation - API and implementation separation.
Its just a common mistake in my case, I just remove default ""flutter:"" keyword in pubspec file while managing package

Categories

Resources