2

Android Studio does not import some widget. widget ImageButon is not impoted

I have tried the following options and all have failed.

1.Invalidate cache and Restart

2.Clean and Rebuild Project

3.Exit AS,delete .iml file and .deal folder,import the project

4.Sync with File Sytem

5.Sync Project with Gradle files.

6.Uninstall AS and reinstall with the same version.

Non of the above have helped,Kindly could someone assist me.

App gradle level

 apply plugin: 'com.android.application'

 apply plugin: 'com.google.gms.google-services'


 android {

compileSdkVersion 29

buildToolsVersion "29.0.2"

defaultConfig {
    applicationId "com.example.viewvideo"
    minSdkVersion 16
    targetSdkVersion 29
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

 dependencies
  {

implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.firebase:firebase-firestore:21.3.1'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'androidx.multidex:multidex:2.0.0'
}

Project Gradle level

buildscript{    

 repositories {

    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.3'
    classpath 'com.google.gms:google-services:4.3.3'

    // NOTE: Do not place your application dependencies here; they     belong
    // in the individual module build.gradle files
}
}

allprojects {

repositories {
    google()
    jcenter()

}
}

   task clean(type: Delete) {

   delete rootProject.buildDir
   }
Gabriel Rogath
  • 710
  • 2
  • 8
  • 23

1 Answers1

1

Update

I think, You are having problem with Android SDK. Remove and reinstall Android SDK will solve the issue


First try to manually import ImageButton inside your ViewActivity for checking class inside the library is available or not

import android.widget.ImageButton;

then Add

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

and remove

buildToolsVersion "29.0.2"

Sync and try again... let me know

majurageerthan
  • 2,169
  • 3
  • 17
  • 30
  • I have try as you have suggested @majuran,But still the same. It seems that the class is not inside the library. – Gabriel Rogath Feb 02 '20 at 17:02
  • I have just Added it – Gabriel Rogath Feb 02 '20 at 17:17
  • Seems everything is fine. Close your Android studio then delete .gradle directory inside your project. Again open your project in Android studio. It'll download libraries again – majurageerthan Feb 02 '20 at 17:20
  • Deleted .gradle directory inside the project but still the same. I think as you @majuran have suggested that the class is not inside the library, and if this is the case how can you handle this? – Gabriel Rogath Feb 02 '20 at 17:34
  • 1
    I didn't face this kind of issue. I think, You are having problem with Android SDK. Removing and reinstalling Android SDK may help u – majurageerthan Feb 02 '20 at 17:41
  • After struggling a whole day with no success,by removing Android SDk and reinstalling it has SOLVED THE PROBLEM. Thank you so much @majuran. You are my hero! – Gabriel Rogath Feb 02 '20 at 18:32
  • You are welcome... I'm happy to know that is working. I updated the last working solution. If it helps, accept this answer as the right solution. Thank you – majurageerthan Feb 03 '20 at 01:40