0

in my project after moving it from one pc to another via usb I started getting errors in every file on almost every line, but the app can still be built and run on an emulator.

From what I can tell android studio is having trouble finding the support-v7 library to import all the files

This is from my main activity:

import android.support.design.widget.NavigationView import android.support.design.widget.Snackbar import android.support.v4.view.GravityCompat import android.support.v7.app.ActionBarDrawerToggle import android.support.v7.app.AppCompatActivity import android.support.v7.widget.DefaultItemAnimator import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.RecyclerView 

And the error message I'm getting is:

Unresolved reference: widget

This is my project level gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.2.61' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.google.gms:google-services:4.0.2' } } allprojects { repositories { google() jcenter() mavenCentral() } } task clean(type: Delete) { delete rootProject.buildDir } 

And this is my app gradle file:

apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 27 defaultConfig { applicationId "com.example.test" minSdkVersion 19 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:design:27.1.1' implementation 'com.google.firebase:firebase-messaging:17.3.1' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'org.jsoup:jsoup:1.11.3' implementation 'com.github.bumptech.glide:volley-integration:4.8.0' implementation 'com.github.d-max:spots-dialog:1.1@aar' implementation 'com.github.bumptech.glide:glide:4.8.0' implementation 'com.google.firebase:firebase-core:16.0.3' implementation 'com.android.support:cardview-v7:27.1.1' implementation 'android.arch.paging:runtime:1.0.1' implementation 'com.android.support:support-vector-drawable:27.1.1' implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1' } apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android-extensions' 

You can also see from this image MainActiviy.kt file that the intelli sens is throwing all kinds of errors, but if I run the it will launch and work perfectly in the emulator or on my device.

And this is from running gradle sync:

Gradle build messages

What I have tried so far:

  • Re synced gradle by changing the app version code
  • Build -> clean project
  • Build -> rebuild project
  • File -> invalidate cache / restart
  • File -> sync project with gradle files
4
  • Why do you have 2 apply plugin: 'kotlin-android-extensions' in your app gradle file? Please remove one and check again. Commented Sep 10, 2018 at 10:40
  • Tried it, same problem Commented Sep 10, 2018 at 10:44
  • 1
    import your project. Don't open from recent projects and open projects. Commented Sep 10, 2018 at 10:46
  • Thank you @Naveen, that solved my problem. If you want, you can post it as an answer and I'll accept it Commented Sep 10, 2018 at 11:02

1 Answer 1

1

Follow Below steps.

  1. Open Android Studio
  2. Go to File - > New -> Import Project
  3. Browse to the project location.
  4. rebuild your project.

That's it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.