After opening an older project for the first time after a few weeks/months (very busy with work) Android Studio asked me to upgrade to the latest gradle plugin.
Gradle Upgrade promt
I didn't really think anything of it and hit "Update". After Gradle finished updating and syncing I noticed that most of my layout and java class files vanished. They're simply gone.
However, in my project's directory a folder called "projectFilesBackup" appeared. I assume that restoring the backup contained in this folder might bring my missing files back.
projectFilesBackup Folder
So my question is: Does anyone know how I actually tell Android Studio to restore to the backup? It only contains an ".idea" folder which contains "workspace.xml". Any help would be greatly appreciated.
I've already tried using "Local History" to undo any changes done on the day of the Gradle Update as detailed in this SO post.
Edit:
As requested my build.gradle files:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath "io.realm:realm-gradle-plugin:1.2.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.tools.awesome.cs.grademanager"
minSdkVersion 23
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'io.realm:android-adapters:1.3.0'
}
Change the realm-gradle-plugin to the most dated one and see if it brings up the files again.
classpath "io.realm:realm-gradle-plugin:2.0.2"
Related
I'm really frustrated. I'm new to Android development and Gradle. Last week I was able to download Android Studio and created a simple app that contains a few buttons. I had no trouble creating and running this.
This week I decided to create another, simpler app with no activities, to check whether my environment is set up properly. After a couple of days, I cannot get the IDE to build the app, and the problems appear to be Gradle-related.
Here is my gradle-wrapper.properties file:
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Here is my app-level build.gradle file:
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 16
targetSdkVersion 29
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'
}
And here is the top-level gradle.build file:
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
}
I read up on additional repositories that are needed, and tried inserting this code into the top-level Gradle build file:
repositories {
google()
jcenter()
maven { url "https://www.jitpack.io" }
}
}
But this does not help. When I try to build the project, I get errors saying that Gradle cannot find files (if I check the "offline" option) or when online, I see errors like this:
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'
In Settings, I have "Auto-detect proxy settings" checked (I'm not behind a firewall), and I'm using Gradle from the gradle-wrapper.properties file.
Given that I'm able to rebuild the app I created last week, but cannot build this new app whatever I try, I'm wondering whether file caching might be causing this trouble. I did try deleting the cached Gradle files from .gradle (I'm running on Windows 10) but that did not help. Multiple times, I have tried invalidating the cache and restarting the IDE but this does not make a difference.
This question already has answers here:
Android Studio 3.1 "Run" not compiling code
(5 answers)
Closed 4 years ago.
I have a weird problem with Android Studio. When I Run my app there are no gradlebuild and etc. just installing app and launch activity which means nothing what I changed in the code will be changed in my apk.
Have you any idea why is this happening?
project level gradle:
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.google.gms:google-services:3.2.0'
classpath "io.realm:realm-gradle-plugin:5.0.0"
// 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
}
app level gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
defaultConfig {
applicationId ""
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
realm {
syncEnabled = true;
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
}
apply plugin: 'com.google.gms.google-services'
You have to fix the Run process in Android Studio.
Look at your main toolbar and find this box:
Click the box and select Edit Configurations....
Make sure the window has the following items in Before launch section:
Gradle-aware Make
Instant App Provision
Click OK.
Run your app.
Try this: File menu -> Invalidate Caches/ Restart. I think it will resolve your problem.
There's been an issue in the 3.1.0 build tools upgrade of Android Studio. Follow these steps to resolve it.
Select Run and click Edit Configurations
Make sure, Gradle-aware Make is Added in TaskList or not. If not then:
click +
select Gradle-aware Make
Leave the task empty and select OK
NOTE: Make sure Gradle-aware Make is before Instant App Provision
Try to following instruction it will surely help you. I already face same problem before couple of month.
* Update ADB in your Android Studio.
* Uninstall application.
* Restart adb start-server.
* Restart you testing device.
I am trying to debug through library code in Android Studio. But it shows unresolved symbols, i.e., red lines at lots of places.
My app build.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.kuldeep.customview"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
My project build.gradle file is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You're looking at the code for TextView, which is an Android platform class and not part of your app. Platform classes can refer to other "package private" classes that are not part of the visible API for an app. Android studio provides for you the ability to view platform source code like this so you can see how it works, but you can't make changes to it and you don't get access to all the actual compiled classes in the SDK.
The short story is that is regular and expected. If you were seeing this for your own app code (not platform classes or add-on libraries) then you'd have something to be concerned about.
2 possible reasons:
Gradle not synced.
Try syncing your gradle files using Gradle Sync.
SDK not updated.
Make sure your SDK is updated and that you have all the extra packages that you need installed. You can do that using SDK Manager.
I am quite new to Android development and trying to write some test code. I have downloaded Android Studio 1.3 version and created testapp. I am trying to add com.facebook.android:facebook-android-sdk:4.1.0 depedency but somehow it's not getting downloaded.
Here is Project level build.gradle file.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
Here is Module level build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.testapp"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:appcompat-v7:22.2.1'
}
After reading other posts on similar topics I also confirmed that Gradle > Global Gradle settings > Offline work is not checked. Still somehow facebook depedency is not getting downloaded.
Any suggestions what could be the issue? Appreciate any pointers.
Thanks.
In your build.gradle you have to add
repositories {
jcenter()
}
It this way gradle knows where are the dependencies to download.
It is somenthing different from the repositories inside the buildscript block.
Otherwise you can add in the top-level build.gradle file:
allprojects {
repositories {
jcenter()
}
}
In this case, the repository block is valid for all modules in the project.
Could you post the error AndroidStudio is showing? (check on the Gradle Console, on the Run section and Android Monitor section)
One possible option that comes to my mind is that you don't have the lastest Android Support repository / Google repository installed: Check for updates on your Android SDK Manager.
Today I updated to Android Studio v 1.0 and I'm getting the following error when trying to compile whatever project.
....\app\build\intermediates\classes\debug: file not found
The thing is that before updating it I had no problems. Here is the code I'm actually trying to compile.
build.grade
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "razvitrance.testnavdrawerplz"
minSdkVersion 16
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v13:21.0.3'
}
build.gradle (for the project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
And the activity code is a simple Navigation Drawer.
Thank you for helping.
This is the erorr i'm getting.
http://gyazo.com/bdf375a160b1662ce4eb0d4e9aed8f30
Check this and this answers.
Generally, you will need to delete your grandle file and let Android Studio generate the one it thinks that it is correct, as it is being mentioned in the given posts. Happened to me too when i upgrated to newer version and that solved my problem.
It seems that Android Studio does not recognize non-alphanumeric symbols in path (cyrillic, for example). I had the same problem, and it was solved with creating project in another folder not containing cyrillic symbols in its path. In your case it may be '#' synmbol that makes a trouble