Using google Place picker in android project - android

I am trying to learn Google's place picker
I have used the sample project from here
I have linked playservices library for the sample project
Resolved all the dependencies
Problem:
Some depedencies r not resolved ther are,
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;
Question:
How to solve this
Should I need to add any other project references

follow this way :
Open the build.gradle file inside your application module directory.
Add a new build rule under dependencies for the latest version of play-services.
For example:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:7.0.0'
}
Be sure you update this version number each time Google Play services is updated.
Save the changes and click Sync Project with Gradle Files in the toolbar.

Answering because I had te same problem.
I needed to add 'com.google.android.gms:play-services-places to my project.
in the app's build.gradle I added
dependencies {
...
compile 'com.google.android.gms:play-services-places:10.2.6'
}

Related

Unable to import in android studio

I am new to android studio. I know how to work in eclipse. I downloaded the sweet alert library for Android from here.
But I am unable to import it because of lack of experience in android studio. Can anyone guide me to import it step by step? I don't even know what a maven/gradle is and how to add as AAR dependency, as mentioned on the website.
Add the following lines to your build.gradle file:
repositories {
mavenCentral()
}
dependencies {
compile 'cn.pedant.sweetalert:library:1.3'
}
The first block makes gradle aware of the maven repository. The second block is shorthand for including the library in the "compile" build step.
Further I sugest that you read the gradle docs here: Gradle plugin user guide
If you are importing Library which is gradle supported then you have to write only one line in your Gradle dependencies
sweet-alert-dialog library is Gradle Supported so you the thing you have to do is open Gradle
dependencies {
compile 'cn.pedant.sweetalert:library:1.3' //add this line
}
download the sweet alert library
In android studio [File] --> [New] -->[Import Module].
Now select the directory where you downloaded sweet alert library.
inside sweet alert library folder select library folder and the click ok.
Now go to your build.gradle(app) in your project and add this line
compile project(":library") into
dependencies {
...
...
...
compile project(":library")
}

Imported module in Android Studio can't find imported class

I recently downloaded the ViewPagerIndicator library and imported it into android studio. After adding it to my project I get a rendering error "The following classes could not be found:" and points to com.viewpagerindicator.IconPageIndicator.
The steps I took were Files->Import Module->'library name', Project Structure -> Dependencies -> + the imported module. Then to my layout xml file I added the <com.viewpagerindicator.IconPageIndicator />, after that I got the missing class problem.
It compiles just fine and I went through all of the build.gradle and settings.gradle files and compared them to what they should be online.
MyApp->build.gradle has compile project(':library') under dependencies
settings.gradle has include ':library' with no build errors.
First of all, you must import your library project by following that path:
File --> New --> Import Module
After you have imported the library project successfully, you must check your build.gradle file inside your project's folder if the following line is present at the "dependencies" section:
implementation project(':NameOfTheLibProject')
Then your project must be built successfully.
I found that my issue was the Android Plugin Version under Project Structure --> Project was different to the version my plugins all used. Once I aligned them to the same version, I could see all my classes from my imported module.
Took me hours :(
I had the same problem. I just did: Invalidate / Restart ..
I too had trouble importing module as it was not appearing in list of modules. And way it worked for me is manually entering it in settings.gradle this way:
include ':app', 'module_name'
And in build.gradle
compile project(':module_name')
In my case, I did add in app gradle:
// Nearly deprecated.
compile project(':NameOfTheLibProject')
// Or
implementation project(':NameOfTheLibProject')
but it only works when I change
compileSdkVersion
minSdkVersion
targetSdkVersion
in app and the other modules are the same.
The following solution worked for me,just two steps.
Go to your project structure on android studio, select project from left side.Change Android plugin version to Gradle version press ok.
If error occurs after synchronization again go to project structure and select project.undo the android plugin version like before.Gradle will align the library and make the class visible to XML files.
The issue in my case was different compile and target SDK version,
mentioned in my main app module and your added lib module.
Once I matched both of them it worked perfectly.
So just open build.gradle file of app-level and lib module-level check for the SDK version.
settings.gradle
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(':wheel') // "Wheel" - you're project path name
}
In case you just changed the name of your project in the pubspec.yaml File, make sure to change the import names as well, because they will stay the same and therefore wont find the new named directory.
Ex. change this to :
import 'package:previousName/backend/connector/userConnector.dart';
to this:
import 'package:newName/backend/connector/userConnector.dart';
As far as i know, there is no terminal command for that, only find-in-files-replace :(

Google Play Game Services + BaseGameUtils added to a Gradle project = package does not exist

I already read many answers on this subject but can't fix my problem, and here it is :
I have a gradle project that is a game, in that game I want to add google game services like I successfully did with 'type-a-number' (which is NOT a gradle project).
But I get the following error:
Gradle: error: package com.google.example.games.basegameutils does not exist
Gradle: error: cannot find symbol class BaseGameActivity
Gradle: error: cannot find symbol variable super
NOTE : in my activity everything that was red because of coming from BaseGameUtils change to normal after the following :
imported BaseGameUtils as a module, added it as a module dependency to my project and check the 'library mobule' box.
imported google-play-services.jar as a library
added to my build.gradle file (the one in my module root) :
dependencies {
compile 'com.android.support:support-v4:18.+'
compile 'com.google.android.gms:play-services:3.+'
}
==> Is there a possibility to add a BaseGameUtils dependencies here ?
tried to check/uncheck the export box of BaseGameUtils dependency
tried to change 'compile' to 'provided'
change the settings.gradle to
include ':MyModule' '(:libraries):BaseGameUtils'
(one time with :libraries, one time without)
Nothing listed above worked..
What I'm doing wrong ?
What I'm missing ?
Your settings.gradle should be:
include ':MyModule', ':BaseGameUtils'
Note the comma.
Your build.gradle for MyModule should also have
dependencies {
compile 'com.android.support:support-v4:18.+'
compile 'com.google.android.gms:play-services:3.+'
compile project(':BaseGameUtils')
}
When I was following the step-by-step here: https://developers.google.com/games/services/android/init
I was hung up on:
dependencies {
compile project(':BaseGameUtils')
// ...
}
and I just needed to change it to:
dependencies {
compile project(':libraries:BaseGameUtils')
// ...
}
hope that helps someone :)

Import scribe-1.2.1.jar in Android Studio

What are the steps to import scribe-1.2.1.jar in android studio?
I have added the jar in the lib folder and have also added it using the add library option. But when I compile I am facing compile time error.
Gradle: package org.scribe.builder does not exist
Edit your module's build.gradle file, just append one line in the dependencies scope.
dependencies {
...
compile files('libs/android-support-v4.jar')
compile files('libs/scribe-1.2.1.jar')
}
FYI: at this time Android Studio project setting did not affect the gradle build, so you must edit it yourself.
there are a user guide for gradle android plugin.

Android Studio cannot resolve symbol common

I followed the migration guide from Eclipse to Android Studio carefully and the only error that I am getting is "cannot resolve symbol common" and is happening on these lines:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
Does anyone know why this would be happening?
The build tool (gradle) can't find the google_play_services library, that define the relevant classes.
Update your build.gradle file, so that it finds the library (at the right path):
[EDIT 2: since 6.5, you can selectively add needed Google Play Services APIs ]
dependencies {
compile 'com.google.android.gms:play-services-base:9.4.0'
compile 'com.google.android.gms:play-services-XXX:9.4.0'
}
[EDIT: newer method, a 'native' support is now provided]
Open SDK Manager, download and install Google Play Services and Google Repository
Edit build.gradle to add:
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
}
[Old method]
Check that google-plays-services is a module in your project, and that its build.gradle contains:
dependencies {
compile files('libs/google-play-services.jar')
}
In your module build.gradle:
dependencies {
compile project(':google-play-services')
}
In my case problem solved using other way i.e. apply plugin.
Open your build.gradle(Module: app) file and add this line to the top below the first line.
apply plugin: 'com.google.gms.google-services'
Code looks like:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
and click on sync now. Problem solved.

Categories

Resources