google-api-java-client library not working in android - android

I am trying to use Google's places API. I downloaded google-api-java-client-1.6.0-beta.zip library and I'm using source code from https://github.com/tuthan/Google-Place-Api-Demo
I import the external library in exactly the correct way, but the code still give me compile time errors on all imports of google-api-java-client-1.6.0-beta.zip.
e.g.
import com.google.api.client.googleapis.GoogleHeaders;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponseException;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.apache.ApacheHttpTransport;
import com.google.api.client.http.json.JsonHttpParser;
import com.google.api.client.json.jackson.JacksonFactory;
I've been working on this for a week, but have been unable to solve it.

The dependency jars are not in your classpath. Please add the jar from google-api-java-client-1.6.0-beta.zip to your sample project.

Related

Upgrade gradle from 3.4 to 3.5 throws "error: cannot find symbol class" and "error: package ... does not exist" in generated DataBindingClasses

we upgrade gradle from 3.4.0 to 3.5.2 and reimported the wrapper with distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip. Unfortunately Android Studio is throwing the following erros multiple times:
error: cannot find symbol class UI
error: package MyPackage does not exist
in my DatabindingClasses app/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/
The missing symbols and packages are all related to mine. So the imports of the generated DataBindingClass looks like this:
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.VideoView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import com.mypackage.mypackage.R;
import com.mypackage.mypackage.UI;
import java.lang.Deprecated;
import java.lang.Object;
After the upgrade I cleaned the project, invalidated the cache, deleted the generated build folder and restarted android studio but without success.
Is there something new in 3.5 which is missed? I read through their release notes and can't find anything.

What is the correct library for Firebase's addValueEventListener?

I'm using multiple different imports with Firebase:
import com.firebase.client.Firebase;
import com.firebase.ui.database.FirebaseListAdapter;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.ValueEventListener;
however, when I try to do
query.addValueEventListener
It doesn't recognize addValueEventListener. I've tried remaking the project and invalidating caches and restarting, but I'm still getting this error. What could possibly be wrong?
The appearance of this:
import com.firebase.client.Firebase;
indicates you are including the legacy Firebase SDK along with the "new" SDK. Not a good practice. Best to update your build.gradle dependencies to eliminate:
compile 'com.firebase:firebase-client-android:2.x.x'
If there are places in your code where you are using the legacy API, you can use the hints in the Upgrade Guide to migrate to the new API.
This should also resolve your other recent question.

import com.google.android.gms.common.api.GoogleApiClient; cannot be resolved

I want to make a login with Google+ login button like this Tutorial
I have copied the codes, set google_play_services libraries, added package name and SHA1 key in google api console, but there are some import errors :
This import is not an error :
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.plus.model.people.Person;
But this import an error (cannot be resolved) :
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.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.plus.Plus;
Anybody have a solution ?
Add this in yourbuild.gradle(app) inside dependency
compile 'com.google.android.gms:play-services:8.1.0'
[Solved]
I try to download new version of google-play-services library and import error is gone.
So, always update/download newest version of google-play-services library..
You need to add the dependency to your app.
Instructions for eclipse here
http://developer.android.com/google/play-services/setup.html
You can also do this by right clicking on your app (if you're using Android Studio) selecting Open Module Settings, going to the dependency tab. Then Clicking the "plus" at the lower left, select library dependency, then find play-services

android BaseGamesUtils library error

I'm trying to implement the google play services in my app. I have successfully imported BaseGameUtils library from GitHub, referenced the GooglePlayServicesLib to the library, but it has a really annoying error...
This is part of the GameHelper.java file :
import com.google.android.gms.appstate.AppStateManager;
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.games.Games;
import com.google.android.gms.games.GamesActivityResultCodes;
import com.google.android.gms.games.multiplayer.Invitation;
import com.google.android.gms.games.multiplayer.Multiplayer;
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch;
import com.google.android.gms.games.request.GameRequest;
import com.google.android.gms.plus.Plus;
Everything is OK except the import com.google.android.gms.games.request.GameRequest; line which is underlined with the error message : com.google.android.gms.games.request cannot be resolved
I have no idea about how to solve this problem, and I see that the help community around google play games services is not as large as I would have bet...
any help would be welcome ! :)
I ran into the same problem. What fixed it for me was updating the google play-services library to a newer version.
Update the google play services library to the latest version. Thanks

The import com.company.projectname.R cannot be resolved

I am developing an application for the company I work for and I am running into an issue with Eclipse. I've been looking online all over and I cannot seem to find a fix for this specific issue. I have changed import android.R; to import com.company.projectname.R; however I get the error "The import com.company.projectname.R cannot be resolved" obviously I replaced company and projectname with the appropriate values.
Here is an example of what the imports should look like:
import android.os.Bundle;
import android.util.Log;
import android.app.ActionBar.Tab;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.ActionBar;
Notice I don't import com.company.projectname.R; Make sure your sdk is updated... After you have done that clean the project.. And rebuild it. You should be fine :D
-Monkey
Try to clean the project, sometimes clean my projects have solved my problems on Eclipse/Android.
If it doesn't work, you can see there if it corresponds with what you did:
Question like yours

Categories

Resources