I have a high priority project under development.
I am trying to insert geo location into db so I found a service online and unfortunately LocationRequest and LocationServices.API are not resolved.
I am using the dependency 'com.google.android.gms:play-services-maps:10.2.0'
I tried adding the imports
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
You can find the code I used at this link
Seems like you need to compile the play-services-location package.
Put these into the build.gradle
ext {
playServicesVersion = '10.2.0' // update accordingly
}
dependencies {
...
compile "com.google.android.gms:play-services-maps:${playServicesVersion}"
compile "com.google.android.gms:play-services-location:${playServicesVersion}"
}
Try this
implementation 'com.google.android.gms:play-services-location:15.0.1'
in your app.gradle, and update the version regularly.
Try this implementation 'com.google.android.gms:play-services:12.0.1'
worked for me
Related
This is for a simple Android app as my first step to test banner ads in an Android app.
I followed examples, guidelines, and arrived at the need for these import lines in MainActivity.java:
// these are needed for advertising:
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
But the builder cannot resolve the last two lines:
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
Why???
I use AndroidX 1.0.0 library (after migrating from Support Library 28.0.0).
The dependencies in build.gradle of the app package are:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.gms:play-services-ads:7.8.0' // added by Henrik to access AdView
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
I have of course added the layout item AdView into activity_main.xml.
I have downloaded Google Play services SDK - it did not help (no change)
I have downloaded Google Repository - it did not help (no change)
What do I miss?
The version you are using is way too old. Use the latest and compatible version. Its already there in Documentation.
implementation 'com.google.android.gms:play-services-ads:19.6.0'
After migrating to Androidx,my project start displaying a red underline error which says could not resolve R.
i have Tried googling for some similar issue but yet the error
remain,
i have checked my manifest, my Res folder for error
i have novalidate/restart project
i have clean and rebuild project
i have sync gradle with android project
yet after i have done these, the error still remains
dependencies {
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
// implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.github.maxyou:CalendarPicker:v1.1.2'
// Ramotion
implementation 'com.ramotion.paperonboarding:paper-onboarding:1.1.3'
implementation 'com.ramotion.foldingcell:folding-cell:1.2.3'
implementation 'com.ramotion.garlandview:garland-view:0.3.3'
}
MyApplication.java
package xyz.esusku.nearbyworker;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}```
See https://twitter.com/tasomaniac/status/1103020923874131968 for the details.
Gradle Android Plugin 3.3+ no longer generates R source file. You either need to update to the IDE that supports the new binary format for the resources or downgrade the plug-in to an older version in your build.gradle.
Hope you have added these line in gradle.properties file: as you are trying to migrate existing project.
android.useAndroidX=true
android.enableJetifier=true
one more thing try removing the duplicate import-
import android.support.v7.app.AppCompatActivity; //remove this line
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
I have added import import com.firebase.ui.database.FirebaseRecyclerAdapter; and
compile 'com.firebaseui:firebase-ui-database:0.4.0'
compile'com.firebaseui:firebase-ui-database:1.1.1'
in my grade files
Still, I am unable to use FirebaseRecyclerOptions
Thanks in advance :)
Gradle dependencies
I'm getting this error:
com.google.android.gms.drive.DriveApi.ContentsResult cannot be resolved
But just with that one import. These all work:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.drive.Contents;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveFile;
import com.google.android.gms.drive.DriveFolder.DriveFileResult;
import com.google.android.gms.drive.MetadataChangeSet;
And for some reason ContentsResult can't be found. Even doing this works:
import com.google.android.gms.drive.DriveApi.*;
And it works in the sense that it doesn't error on the import, but when I do that, ContentsResult still just cannot be found...
Has anyone had this issue before?
There is no ContentsResult class in the DriveApi package, but there is a DriveContentsResult class:
com.google.android.gms.drive.DriveApi.DriveContentsResult
See http://developer.android.com/reference/com/google/android/gms/drive/package-summary.html
The answer 'myanimal' gave you is correct. You are probably using some older version of GDAA code, since 'ContentsResult' used to be there see here. Please make also sure you are compiling with the latest 'play-services:6.5.87'. I'm not sure it you are using Android Studio. If yes, see if your 'build.gradle' config file has the dependencies right:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
....
....
}
Disclaimer: It is not a 'better' answer, just an extension of "myanimal's" answer below.
I am new to intellij13 and just imported my Android project into it. however get the following errors and tried adding dependencies but cannot work.
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.TextView;
those are my imports
Going out on the limb here, but you probably need to add android-support-v4.jar to your project dependencies (in the /libs folder). If you are using Gradle, then add:
dependencies {
compile 'com.android.support:support-v4:19.1.+'
compile 'com.android.support:appcompat-v7:19.+'
}
in your build.gradle file