Can Not Perform Copy-Paste in Android Studio - android

I have faced two main problems in Android Studio. First of all I can not perform copy-paste and cut-paste (ctrl+c - ctrl+v - ctrl+x) abilities in some classes. To fix that problem, I click "invalide caches/restarts", but it breaks down again immediately.
Second problem is (I think it is related to the first problem) compiler does not recognize already defined methods and attributes. Auto suggestion etc. does not work.
The steps I've taken to try to fix the problem are;
File -> invalide caches/restarts,
File -> Power Save Mode -> Disable,
Close all opened tabs and fresh restart,
File -> Sync Project with Gradle Files,
File -> Sync with File System,
Delete JDK and reinstall,
Delete Android Studio and reinstall,
Delete already downloaded SDK files and ".Android" folder,
Disable and delete all plugins.
Checked copy-paste keymap in File -> Settings -> Keymap
Pulled the project from bitbucket to different 2 computers
Created new project, copy whole project classes with NotePad++ to
new Project
Try to convert all Java codes to Kotlin, cannot convert
Here is my system specifications; Windows 10 Home Single Language (TR), version 1909. 16 GB ram. Android Studio 3.5.3 and Gradle Version 3.5.3
I have read all post about the same problem but there is no luck (The posts are only about MAC and Linux platform).
UPDATE 1.0 ->
I have discovered that some classes cannot do the operations described above, but some classes can.
I realized that, There are no icons for classes that cannot do the operations I have described above. (Sometimes magically appears "J" icons and when I clicked another class, this J icon disappears immediately.) I think gradle or file system of Android Studio does not recognize these files as classes.
UPDATE 2.0 ->
I have noticed that when I clicked the Structure section of DuoFragment (Which has 500+ lines codes and one of the uncompiled class) cannot load anything. Is DuoFragment size is bigger to process?
Also when I checked the Build section, some processes cannot run (I do not know if this is normal or not);
Task :app:compileDebugAidl NO-SOURCE,
Task :app:compileDebugRenderscript NO-SOURCE,
Task :app:processDebugJavaRes NO-SOURCE
UPDATE 3.0 ->
Here are my Gradle files.
Project Level Gradle file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level Gradle file.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.lotusif.dump2"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.core:core:1.1.0'
// material widgets
implementation 'com.google.android.material:material:1.2.0-alpha03'
// progress bar with text
implementation "com.github.skydoves:progressview:1.0.3"
// sequence progress
implementation 'com.github.transferwise:sequence-layout:1.0.11'
// flash bar
implementation 'com.andrognito.flashbar:flashbar:1.0.2'
// toggle - switch button
implementation 'com.github.GwonHyeok:StickySwitch:0.0.15'
// Custom Toast message
implementation 'com.github.GrenderG:Toasty:1.4.2'
// liquid effect bar
implementation 'com.mikhaellopez:circularfillableloaders:1.3.2'
// bubble tab bar
implementation 'com.fxn769:bubbletabbar:1.0.3'
//glide image library
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
// scaling layout
implementation 'com.github.iammert:ScalingLayout:1.2.1'
// lottie animation
implementation 'com.airbnb.android:lottie:3.3.1'
//Gson
implementation 'com.google.code.gson:gson:2.8.6'
//RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.15'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.daimajia.easing:library:2.1#aar'
implementation 'com.daimajia.androidanimations:library:2.3#aar'
//retrofit
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'
}
UPDATE 1.0 Images
UPDATE 2.0 Images

UPDATE --> There is a bug in Kotlin libraries with Windows 10 Single Language Turkish. (Maybe some of other Single Language Windows distributions have same issue, I haven't known yet.) Kotlin's some libraries cannot work on Turkish operating system. I solved this problem with installing Windows 10 Pro English.
Other developers who use Windows 10 Single Language Turkish faces same problem with different angles. (Example1 and Example2)
OLD ANSWER
TL;DR -> Problem is about third party libraries that are written with Kotlin. I have converted my Java project to Kotlin and all problematic third party libraries work well. Problem is about Java - Kotlin conflict.
I would like to share how I solved the problem for those who will face such problems later.
I did all the steps I mentioned above one by one but I could not find any solution and I decided to examine my third party libraries.
First of all, I disabled all third party libraries and looked at the status of my classes that did not recognize already defined methods and attributes. After disabling third party libraries and making Rebuild Project and Sync Gradle, the Auto Suggestion feature of those corrupted classes started working again.Then, uncovering which third-party libraries were problematic, I activated those third-party libraries one by one. I found which third party libraries broke my project.
There were 4 third party libraries that broke my project : StickySwitch, ProgressView, SequenceLayout and Flashbar. When I removed those libraries, everything worked right. After removed the libraries, my Gradle file was as below.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.lotusif.dump2"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.core:core:1.1.0'
// material widgets
implementation 'com.google.android.material:material:1.2.0-alpha03'
// progress bar with text BUGGY!
// implementation "com.github.skydoves:progressview:1.0.3"
// sequence progress BUGGY !
// implementation 'com.github.transferwise:sequence-layout:1.0.11'
// flash bar BUGGY !
// implementation 'com.andrognito.flashbar:flashbar:1.0.2'
// toggle - switch button BUGGY !
// implementation 'com.github.GwonHyeok:StickySwitch:0.0.15'
// Custom Toast message
implementation 'com.github.GrenderG:Toasty:1.4.2'
// liquid effect bar
implementation 'com.mikhaellopez:circularfillableloaders:1.3.2'
// bubble tab bar
implementation 'com.fxn769:bubbletabbar:1.0.3'
// android chart library
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
//glide image library
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
// scaling layout
implementation 'com.github.iammert:ScalingLayout:1.2.1'
// lottie animation
implementation 'com.airbnb.android:lottie:3.3.1'
//Gson
implementation 'com.google.code.gson:gson:2.8.6'
//RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.15'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.daimajia.easing:library:2.1#aar'
implementation 'com.daimajia.androidanimations:library:2.3#aar'
//retrofit
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'
}
So, what was the common feature of those libraries that corrupt my project? My project was written with Java but that libraries were written with Kotlin. One second, cannot I use Kotlin libraries in my Java project? Yes, I can. I have to add android.useAndroidX=true and android.enableJetifier=true in my gradle.properties, that is it. But what if I have already added those lines in my gradle.properties and it has not worked?
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
I have not understood why kotlin libraries cannot work with my Java project. As you can see in my Gradle file, I am using apply plugin: 'kotlin-android' and apply plugin: 'kotlin-android-extensions' for Kotlin support.
How I have rescued my project? There were 2 available options as I knew. While first method was that to removed those 4 third party libraries and could not use them, second one that to convert all Java classes to Kotlin classes (I tried it before but it did not work until disabled all third party libraries). I chose to convert all Java classes to Kotlin classes. Thus, I was able to use 4 third party libraries which were mentioned above.
It took me 30 days to solve this problem. Now, I am working on Kotlin language. As a result, my project is running without any problem.

Related

androidx migration problem with several libraries

I have migrated to androidx recently and faced these problems.
Problem :
My configuration
build.gradle(app) :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.crazy.tuhin.aroundme"
minSdkVersion 16
targetSdkVersion 28
versionCode 5
versionName "1.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
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.android.material:material:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
//google
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
}
build.gradle(project) :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.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
}
gradle-wrapper.properties :
#Fri Apr 10 02:21:34 IST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
settings.gradle :
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
My android studio version :
Android Studio 3.6.2
My question is do I have to change every import manually? but I have this android.enableJetifier=true
Can you please point out the problem? The already mentioned problems and solutions here are not helping.
Thanks.
My question is do I have to change every import manually?
Yes, you've to.
android.enableJetifier=true helps migrate third-party dependencies to use AndroidX. Jetifier will change the byte code of those dependencies to make them compatible with projects using AndroidX.
Following are the proper steps to migrate -
Preparing to migrate
Before you start to migrate to AndroidX you should:
Create a new branch on which to make the migration changes.
If possible, suspend or minimize development ( at least don’t try to do refactoring or pull in new features ) during the migration, as this will help reduce the number of merge conflicts that could happen.
Migrate
Throughout the migration steps focus on addressing errors, getting your app to compile, and passing all tests.
Step 1:
Migrating directly to AndroidX from an older version of the Support Library, say 26 or 27, isn’t recommended. Bring the app up to date. Update the project to use the final version of the support library: version 28.0.0. This is because AndroidX artifacts with version 1.0.0 are binary equivalent to the Support Library 28.0.0 artifacts. Then address all of the API changes, and ensure your app compiles with version 28.
Step 2:
Update third-party dependencies to the latest. Not doing so could result in unexplained compilation errors.
Step 3:
Enable the following flags in gradle.properties. With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
android.enableJetifier=true - Jetifier helps migrate third-party dependencies to use AndroidX. Jetifier will change the byte code of those dependencies to make them compatible with projects using AndroidX.
android.useAndroidX=true - The Android plugin uses the appropriate AndroidX library instead of a Support Library.
SOLVED
If you run into an unfortunate problem like mine, do these:
1. Delete all unused imports (grey coloured) from every class.
2. Now import the required classes like this :
3. Repeat for every related class.

Library module doesn't include dependencies in Android

I am working on a multi-module project and this project should have a Java Library module called test-shared to provide common test classes. However, I am facing an issue in which my module doesn't recognize dependencies and I cannot write my classes.
Things have been done
Enable offline mode and disable again.
Delete .gradle folder and sync.
Googled identical issues.
Invalidate cache & restart.
As a result, I don't have a working project. Your help would be welcome.
build.gradle
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.2"
implementation "androidx.test:rules:1.2.0"
implementation "androidx.lifecycle:lifecycle-runtime:2.1.0"
implementation "androidx.lifecycle:lifecycle-extensions:2.1.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.1.0"
}
sourceCompatibility = "8"
targetCompatibility = "8"
Example class
class Co {
val a = LiveData<Co>()
val b = Observer<Co>()
}
In this example, neither LiveData nor Observer are recognized. Could you please help me fix this weird issue?
Thanks,
If this is not the entirety of your library's gradle file, then you are missing the android plugins.
Please add the following at the top of your library's gradle file.
apply plugin: "com.android.library"
I will also recommend having a look at the documentation: https://developer.android.com/studio/projects/android-library

Error: Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0 [duplicate]

My android app Gradle build is not syncing, since I updated my android studio to 3.2. I have updated everything in the dependencies and still getting the same error. Here are the dependency files that I use ( Including third-party libraries)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myappid"
minSdkVersion 19
targetSdkVersion 28
versionCode 32
versionName "3.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.11"
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1'
implementation 'com.android.support:cardview-v7:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-crash:28.0.0-alpha1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.anko:anko:$anko_version"
implementation 'com.github.GrenderG:Toasty:1.2.5'
implementation 'com.github.scottyab:showhidepasswordedittext:0.8'
implementation 'com.daimajia.easing:library:2.1#aar'
implementation 'com.daimajia.androidanimations:library:2.3#aar'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
implementation 'com.google.gms:google-services:4.2.0'
implementation 'com.github.sd6352051:NiftyDialogEffects:v1.0.3'
implementation 'net.steamcrafted:load-toast:1.0.12'
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha1';
}
//apply plugin: 'com.google.gms.google-services'
//classpath 'com.google.gms:google-services:4.2.0'
However, I am getting the following error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
I have tried most things available through Google/Youtube searches. Implemented few answers given in StackOverflow too. But at the end of the day, it's the same error. What I am missing.
Please advice, how to resolve the issue. Thank you
So the problem doesn't necessarily needs to be in your application level build.gradle script (the one you posted). It can also be in the project level one or even in the maven-publish-aar.gradle one (if you have it). This means, you could be using deprecated Gradle features on any Gradle script.
I have updated everything in the dependencies and still getting the same error.
Most likely, the warning will be gone once you identify and replace any deprecated Gradle feature that's causing you this trouble. To do this, it will help you to actually add the mentioned --warning-mode=all flag to your Gradle command line options (on your Android studio compiler settings):
This will print the proper warnings for you to be aware of what are the specific deprecated features your app is using.
In my case (for example), I just added the enableFeaturePreview('STABLE_PUBLISHING') setting on the settings.gradle file and that did the magic (I'm using publishing{}).
Also, I know you asked this near a month ago, but, it might be useful for other people facing the same issue.
Had same issue yesterday extended to the #Hugo Allexis Cardona answer even after replacing deprecated Gradle feature having same issue because Old build folder is remains there so what I did is Remove app/build folder and sync gradle again and it work for me Thanks #Hugo Allexis Cardona
Delete App/Build Folder
The Problem is because of the inconsistency of external dependencies.
The Issue can be Easily Solved by migrating to Yarn Package Manager
Delete Node Modules
Delete Package.json.lock
yarn install
OR
Try Deleting android/app/build folder
The run the project by react-native run-android
I found easiest way to solve this issue. Go to projectName/android directory and in terminal enter the following command
./gradlew clean
And then, go to main project directory by entering following command
cd ..
And then start the project
react-native run-android
In my case
I Followed Hugo's answer
Changed the location of project.
Tried another android device [Build and success install]
Tried on my android device [Build and success install]

Deprecated Gradle features making it incompatible with Gradle 5.0. Android Studio 3.2

My android app Gradle build is not syncing, since I updated my android studio to 3.2. I have updated everything in the dependencies and still getting the same error. Here are the dependency files that I use ( Including third-party libraries)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myappid"
minSdkVersion 19
targetSdkVersion 28
versionCode 32
versionName "3.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.11"
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1'
implementation 'com.android.support:cardview-v7:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-crash:28.0.0-alpha1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.anko:anko:$anko_version"
implementation 'com.github.GrenderG:Toasty:1.2.5'
implementation 'com.github.scottyab:showhidepasswordedittext:0.8'
implementation 'com.daimajia.easing:library:2.1#aar'
implementation 'com.daimajia.androidanimations:library:2.3#aar'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
implementation 'com.google.gms:google-services:4.2.0'
implementation 'com.github.sd6352051:NiftyDialogEffects:v1.0.3'
implementation 'net.steamcrafted:load-toast:1.0.12'
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha1';
}
//apply plugin: 'com.google.gms.google-services'
//classpath 'com.google.gms:google-services:4.2.0'
However, I am getting the following error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
I have tried most things available through Google/Youtube searches. Implemented few answers given in StackOverflow too. But at the end of the day, it's the same error. What I am missing.
Please advice, how to resolve the issue. Thank you
So the problem doesn't necessarily needs to be in your application level build.gradle script (the one you posted). It can also be in the project level one or even in the maven-publish-aar.gradle one (if you have it). This means, you could be using deprecated Gradle features on any Gradle script.
I have updated everything in the dependencies and still getting the same error.
Most likely, the warning will be gone once you identify and replace any deprecated Gradle feature that's causing you this trouble. To do this, it will help you to actually add the mentioned --warning-mode=all flag to your Gradle command line options (on your Android studio compiler settings):
This will print the proper warnings for you to be aware of what are the specific deprecated features your app is using.
In my case (for example), I just added the enableFeaturePreview('STABLE_PUBLISHING') setting on the settings.gradle file and that did the magic (I'm using publishing{}).
Also, I know you asked this near a month ago, but, it might be useful for other people facing the same issue.
Had same issue yesterday extended to the #Hugo Allexis Cardona answer even after replacing deprecated Gradle feature having same issue because Old build folder is remains there so what I did is Remove app/build folder and sync gradle again and it work for me Thanks #Hugo Allexis Cardona
Delete App/Build Folder
The Problem is because of the inconsistency of external dependencies.
The Issue can be Easily Solved by migrating to Yarn Package Manager
Delete Node Modules
Delete Package.json.lock
yarn install
OR
Try Deleting android/app/build folder
The run the project by react-native run-android
I found easiest way to solve this issue. Go to projectName/android directory and in terminal enter the following command
./gradlew clean
And then, go to main project directory by entering following command
cd ..
And then start the project
react-native run-android
In my case
I Followed Hugo's answer
Changed the location of project.
Tried another android device [Build and success install]
Tried on my android device [Build and success install]

apt dependency scope in Android gradle - what is it used for?

What is the apt dependency scope in android gradle files i see sometimes ?
An example looks like this?
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "org.ligboy.test.card.module1"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
final DAGGER_VERSION = '2.0.2'
dependencies {
compile "com.google.dagger:dagger:${DAGGER_VERSION}"
apt "com.google.dagger:dagger-compiler:${DAGGER_VERSION}"//what is this scope
provided 'org.glassfish:javax.annotation:10.0-b28'
}
and in the top level build.gradle file it has this global dependency:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
Notice in the dependencies section there is a apt scope ? i only know of compile, package and provided scope. compile
includes the dependency at compile time and in your package, provided says only include the library at compile time and discard it at
package time so its not included in final build. and Package is the reverse, it includes the dependency in the package and not at compile time.
But what is apt dependency scope which we obviously need the com.neenbedankt.android-apt for it to work so i know its android based.
update:
why cant i use provided dependency scope instead of apt scope ? How do they differ ?
i created a tutorial on dagger dependency scopes for those who need more info.
From the android-apt project page:
The android-apt plugin assists in working with annotation processors in combination with Android Studio. It has two purposes:
Allow to configure a compile time only annotation processor as a dependency, not including the artifact in the final APK or library
Set up the source paths so that code that is generated from the annotation processor is correctly picked up by Android Studio.
You are using Dagger, which uses annotation processing to generate code. The annotation processing code shouldn't be included in the final APK, and you want the generated code to be visible to Android Studio. android-apt enables this behavior.
This sounds very similar to the provided scope, but apt differs from provided in a few key ways. The first difference is that code generated by an apt dependency is available to the IDE, whereas code generated by a provided dependency is not.
Another important difference is that the code in a library using the provided scope is on the IDE classpath (i.e. you can import the classes and attempt to use them), whereas code in an apt dependency is not. With provided, your code will crash at runtime if you don't actually provide the referenced dependencies with a compile scoped counterpart.
You can find a discussion about apt vs provided on this android-apt issue.
In the case of Dagger, there should be no reason to include the annotation processor and code generator in any of your code (which the provided scope would allow). Thus the apt scope is more appropriate.
Update for October 2016:
You probably don't need apt and the android-apt plugin anymore. Version 2.2 of the Android Gradle plugin has an annotationProcessor configuration that you should be using instead.
See more at What's next for android-apt?
Just to add how to change this in Studio 2.2 +
dependencies {
compile 'com.google.dagger:dagger:2.4'
annotationProcessor "com.google.dagger:dagger-compiler:2.4"
}
Add this in apps gradle module. No need to change any other thing.
Happy coding :)

Categories

Resources