I've been looking far and wide for solutions to this but alas in my sample project I still get the following errors
"The method isDetached() is undefined for the type Fragment"
"The method detach(Fragment) is undefined for the type FragmentTransaction"
What is the matter here? I have the following imports
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabContentFactory;
And I use SDK version 8
<uses-sdk android:minSdkVersion="8" />
Make sure that the jar file you're importing is the most recent one. There are a few android-support-v4.jar files and I've caught a few differences in the APIs they implement.
Download it again and make sure that you import the most recent file in eclipse.
Related
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.
This import statements in the MainActivity are giving errors(after migration to androidx), what to do?
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.design.widget.NavigationView;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
Please remove your all appcompat-v7 and other implementation for androidx you need androidx libraries like below
import com.google.android.material.floatingactionbutton.FloatingActionButton
import androidx.appcompat.widget.Toolbar
import androidx.appcompat.app.AppCompatActivity
As Vipul Prajapati said, I manually changed all the package names by going to: https://developer.android.com/jetpack/androidx/migrate
searching for my existing package and then replacing by androidx specific ones.
I also made the following changes to my
gradle.properties
file.
android.useAndroidX=true
android.enableJetifier=true
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
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
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.