Cannot Resolve R after Update Android Studio to v13 - android-studio

I've got problem when executing gradle after my android studio updated to version 1.3
So this is the error message
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Otniel\AppData\Local\Android\sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1
I don't know what was happened, but this is my approach to fix my error (which is not produce any working solution)
change my build tools from project structure settings :
compile sdk version : API 22: Android 5.1
build tools version 22.0.1
(sync gradle and error still the same with the above message)
Then I continue the first setting (point 1) and add this 2nd setting
2. change gradle 1.2.3 to classpath 'com.android.tools.build:gradle:1.3.0'
(1.2.3 produce the same error as the message above)
(with 1.3.0 still produce the same error)
try to revert back the build tools to v 21 and android lolipop v 5
with combination of gradle : com.android.tools.build:gradle:1.3.0, and com.android.tools.build:gradle:1.2.3
When I revert to 1.1.3 or 1.0.0 (for the gradle plugin) I still got the same error.
When I change the gradle to 1.1.3, the console returns a message to use the gradle plugin version that match with build tools sdk (v 24)
But every combination that I use is still return an error message (still the same, like the message above)
Also I've tried to delete impl and .idea folder, and reimport the project, still have the same error.
And my android studio cannot resolve R symbol as the effect.
So what should I do to fix this?
[EDITED]
This is my gradle code :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.vanwellis.vinnomobile"
minSdkVersion 15
targetSdkVersion 21
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:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:support-v4:21'
compile 'com.daimajia.easing:library:1.0.0#aar'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'commons-io:commons-io:2.4'
compile 'com.daimajia.androidanimations:library:1.1.2#aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'jp.wasabeef:recyclerview-animators:1.0.3#aar'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.google.code.gson:gson:2.3.1'
}
I got these 2 errors, after seeing it carefully :
D:\Projects\Android\MyProj\app\build\intermediates\res\merged\debug\drawable-hdpi-v4\ic_launcher.png: error: Duplicate file.
D:\Projects\Android\MyProj\app\build\intermediates\res\merged\debug\drawable-hdpi\ic_launcher.png: Original is here. The version qualifier may be implied.
Maybe my additional information are usefull

After updating Android Studio recently, I also had this problem. What worked for me was to expand res, then go through every child folder in res and expand them (you can close them right after.)
Close all classes you have open and in the system bar select Build > Make Project.

Related

Android studio AAPT: error failed writing to R.txt: the data is invalid

I am having an issue with building new projects on android studio. I keep on getting the error:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
AAPT: error: failed writing to 'D:\Libraries\Documents\AndroidStudio\SocketTest\app\build\intermediates\runtime_symbol_list\debug\R.txt': The data is invalid. (13).
Here is my project build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.sockettest"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
This problem only occurs on new projects I try to build and isn't an issue on older ones.
I have read through R.txt': The data is invalid. (13) which leads to Long package name build error in Android Studio which still does not solve the problem.
I only encounter this issue while using windows 10 (update 1909), and not while using android studio on ubuntu. I am running android studio version 3.6.2
I know this is a year late but could it be an antivirus blocking it? This is what Avast came up with:
In case someone new to android studios like me does not know how to downgrade Gradle and plugin, here's how (windows):
Select File>Project Structure.
Type in (3.6.3) the Android Gradle Plugin Version.
Type/select (6.0) from dropdown menu the Gradle Version.
Hit OK to Save.
Android Studios will download and set up the new Gradle for the current project. This resolved the data is invalid error for me.
Was getting the same error. I realized it had something to do with the Gradle version I was running, even though I usually stick to the stable channel of releases. I ended up downgrading to plugin version: 3.6.3 & Gradle version 6.0. I had previously been on plugin version 4.0.0 & Gradle version 6.1.1.
I don't know if this was for sure the same issue, this was happening to any projects on my Win10 PC (ver 2004) that were running that Gradle version.
Please follow this :
Uninstall your System(Windows OS)anti virus and most probably it will work.
I already solved by adding this in my dependency
implementation 'com.android.support:design:28.+'
I had a similar issue trying to build an ionic capacitor app with android studio. I later discovered that one of the directories' names in the project's path has space in the name.
I just copied the project into another directory to form a path that has no space and recompiled the project and the error vernished.

How to fix "Unable to load class 'com.android.builder.errors.EvalIssueReporter'." error on Android Studio 3.2.1

I use IntelliJ IDEA for creating #Flutter projects and I have the Android Studio for installation purposes of Flutter onto my machine. The problem arose when I upgraded the Android Studio from 3.1.4 to 3.2.1. Moreover, after this upgrade, I'm no longer able to create any project in both IDEs.
The error message in IntelliJ
The error message in Android Studio
P.S. Those are the default programs of both IDEs namely, IntelliJ and Android Studio.
any newly-created project brings up this error; however, previously-created projects work perfectly fine.
My machine has 64-bit OS, x64-based Processor
IntelliJ
IntelliJ IDEA 2018.3.3 (Community Edition)
Build #IC-183.5153.38, built on January 9, 2019
JRE: 1.8.0_152-release-1343-b26 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Android Studio
Android Studio 3.2.1
Build #AI-181.5540.7.32.5056338, built on October 9, 2018
JRE: 1.8.0_152-release-1136-b06 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
project's build.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.2.1'
// 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
}
the individual module build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.nonna.myapplication"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
}
I have checked those questions but unfortunately, the error wasn't fixed.
Build errors after Android Studio 3.2.1 upgrade
Could not find com.android.tools.build:aapt2:3.2.0
This issue got solved and now the IDE is working like a charm.
As it was seen from the provided screenshots there was an error in the Android Gradle plugin, so to solve this issue follow the numbered steps in the newly provided screenshots below.
(Part 1) Solving gradle issue due to upgrading Android Studio to 3.2.1
Step 0: From the left panel in your IDE, choose the android
[name_of_project] folder
Step 1: look for the build.gradle file then double click it to
start editing it
Step 2: change exactly the line that states
classpath
'com.android.tools.build:gradle:3.2.1' to the current version of
your Android Studio, in other terms, classpath
'com.android.tools.build:gradle:3.3.0' in my case.
(Part 2) Solving gradle issue due to upgrading Android Studio to 3.2.1
Step 3: After finishing from Steps 1 & 2, go to the gradle folder
Step 4: Double click on the wrapper subfolder
Step 5: Click the gradle-wrapper.properties file to start editing
it
Step 6: make sure that your gradle version is compatible with your
current Android Studio
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
The Android Gradle plugin 3.3.0 requires the Gradle version of 4.10.1 and newer.
Disclaimer: you need to do these steps whenever you create a new project on whatever IDE you use namely, Android Studio, IntelliJ IDEA, and VS Code.

Android Studio 3.0.1 (Windows 10 64-bit) stuck at "Executing tasks: [:app:assembleDebug]" when building project

The process gets stuck if I am trying to run the app (even when I start from a fresh new project) both on an emulator (Android 5.0 or 6.0) or on my phone (Android 7.1). Following some results I found online, I tried to run gradle offline but it did not work. I did also try the solutions suggested on this link, with no success. On Ubuntu, this seems to be caused because of a library issue concerning 32-bit software running from a 64-bit system, which can be solved installing the appropriate library, but I could not find any guidance when running Android Studio on Windows.
The build.gradle file (Module: app) says:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.denny.zuzuplayer"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
The build.gradle (Project) says:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// 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
}
Thanks!
I noticed that Android Studio has a tab called Gradle Console, which lists every gradle process that is currently running, in detail. That is how I got the message that the "aapt" instance was not fine the old rascal, due probably to the antivirus software. This is what the console told me:
> Exception in thread "queued-resource-processor_16"
> java.lang.RuntimeException: Timed out while waiting for slave aapt
> process, make sure the aapt execute at
> C:\Users\Denny\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt2.exe
> can run successfully (some anti-virus may block it) or try setting
> environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5
> seconds
I have no idea how to "set environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds". I Googled the issue for a few minutes when I wondered, why not try the other possible solution first?
I added the SDK folder to my antivirus exceptions (aapt is an instance of SDK, for that matter), and voilĂ , the project is finally building. Hurray!
I just got this error and was able to resolve it by ensuring that the two Glide libraries I'm using refer to the same version.
This caused the error:
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
And this fixed it:
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
I was able to determine that the error was related to the Glide libraries, at least my configuration of them in the module's build.gradle file, by using Denny's suggestion to examine the Gradle tasks. Opening the Gradle Tool Window shows a list of tasks. The Event Log indicated that the error was related to the "assembleDebug" task. So, I double-clicked on that task in the Gradle Tool Window to execute it, and some useful information appeared in a tab on the Run console.

How to port C library into into Android studio JNI folder

I have a program, which I have compiled using the arm toolchain in NDK. Now I want to use it as a library; put it in the JNI folder and call the functions from my main activity. I want to know how to go about this efficiently and intelligently. I copied all the files, and folders over to the JNI folder. What do I do about the make files in my native C code? Can I modify them to fit the JNI setup? Can anyone help with what items I need to address please? Note, my question is not about porting the native code, rather how to do it effectively. And I am trying to figure out if there are any automation tools in IDE that would help me do this please.
Right now, I get the following error, which I believe tells me that the old make file I copied over is not producing a file that is needed by the project? Am I right?
Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/sansari/ndk/android-ndk-r10d/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/sansari/AndroidStudioProjects/NDKSample/app/build/intermediates/ndk/debug/Android.mk APP_PLATFORM=android-21 NDK_OUT=/home/sansari/AndroidStudioProjects/NDKSample/app/build/intermediates/ndk/debug/obj NDK_LIBS_OUT=/home/sansari/AndroidStudioProjects/NDKSample/app/build/intermediates/ndk/debug/lib APP_ABI=all
Error Code:
2
Output:
make: *** No rule to make target `/home/sansari/AndroidStudioProjects/NDKSample/app/build/intermediates/ndk/debug/obj/local/arm64-v8a/objs/myLib//home/sansari/AndroidStudioProjects/NDKSample/app/src/main/jni/tools/arm-eabi-4.7/lib/gcc/arm-eabi/4.7/crtn.o', needed by `/home/sansari/AndroidStudioProjects/NDKSample/app/build/intermediates/ndk/debug/obj/local/arm64-v8a/libmyLib.so'. Stop.
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.sansari.ndksample"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
ndk {
moduleName ="myLib"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
The story behind this project is that I created it using a tutorial. In it, the author used mylib. So the error I am getting says that the make file I just moved into the JNI folder does not have a line for building mylib.so. Is that right? I looked at the make file at the root of my C code, and that does not look anything like target/dependency structure that I read about in the first few chapters of GNU make. Can you help me find the make file I need to update in order to build mylib.so?
I found some information about my question. By default build.gradle ignores the existing make files in a native project. And you have to put in your own Android.mk and Application.mk files in the Android Studio.
I found out I have to add Android.mk and application.mk to a native project in Android Studio if I am looking to port a large project into Android Studio.

Is the Android Support Library required when using Google Mobile Ads?

I'm using Android Studio and when I try to "Sync Project with Gradle Files" or "Clean Project" it fails. I see the message:
Gradle 'MyTestProject' project refresh failed:
Artifact 'com.android.support:support-v4:19.1.0:support-v4.jar' not found.
I see in my MainActivity that import com.google.android.gms.ads.*; is having a problem, saying, "Cannot resolve symbol 'android'."
I don't even know if these two are related. In the past, I have been able to add support-v4 to the dependencies, and everything was fixed. However, I am trying that again right now, and I get the same project refresh failed message.
Oh yeah... my minSdkVersion is 14, and my targetSdkVersion is 19.
Any ideas?
EDIT:
Ok, I forgot to mention that I am including the Google Play Services as a dependency, but that doesn't help. For testing, I went ahead and created a new, bare-bones, project and gradle syncs fine if I don't touch it. However, as soon as I add the Google Play Services dependency to the gradle file, I get the same fail message noted above. Here is my gradle file and that fail message once again:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Message:
Gradle 'SimpleExample' project refresh failed:
Artifact 'com.android.support:support-v4:19.0.1:support-v4.jar' not found.
I'm thinking that something else must be going on?
You need to add the Google Play Services dependency:
compile 'com.google.android.gms:play-services:4.4.52'

Resources