Some file crunching failed, mergeDebugResources FAILED - android

This error occurred today after I updated Android Studio from 2.2 to 2.3 , and run app to my phone. Everything was OK last Friday. This Monday gift ruined my all day.
Gradle setting is "Use local gradle distribution", version 3.3 .
log info as below, because it's too long and all of them are similar, I just copied some segments:
Error: Some file crunching failed, see logs for details
:app:mergeDebugResources FAILED
AAPT: \\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-mdpi-v4\abc_btn_switch_to_on_mtrl_00012.9.png ERROR: Unable to open PNG file
AAPT: \\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-xxhdpi-v4\abc_ic_star_half_black_48dp.png ERROR: Unable to open PNG file
AAPT: \\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-hdpi-v4\abc_ic_menu_share_mtrl_alpha.png ERROR: Unable to open PNG file
AAPT: \\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-xxhdpi-v4\abc_text_select_handle_middle_mtrl_light.png ERROR: Unable to open PNG file
AAPT err(Facade for 925134644) : No Delegate set : lost message:\\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png ERROR: Unable to open PNG file
AAPT err(Facade for 925134644) : No Delegate set : lost message:\\?\C:\Users\任\.android\build-cache\41cfce3bb6e2ca4b269727fe91725c24a067ec68\output\res\drawable-mdpi-v4\abc_switch_track_mtrl_alpha.9.png ERROR: Unable to open PNG file
build.gradle as below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
aaptOptions {
cruncherEnabled = false
}
defaultConfig {
minSdkVersion 18
targetSdkVersion 18
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
}
}
useLibrary 'org.apache.http.legacy'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'org.jetbrains:annotations-java5:15.0'
}
}
According to advice from other questions, although some answers are just too outdated, still I have tried following ways, unfortunately, none of them saved me:
1. remove all .9.png files from my project.
2. check all png files are real PNG.
3. insert following settings to build.gradle :
aaptOptions {
cruncherEnabled = false
}
4. check project file path, not reaching 255 characters (Windows 10).
5. clear gradle caches.
6. Invalidate caches and restart.
7. clean project.
I think log info leads me to files auto-generated by Android Studio. Trying to search error .png files, none of them exists in my project.
Any advice is appreciated.

problem solved. The solution is here.
Related data as below:
1. According to release notes of Android Studio version 2.3, build cache is enabled by default.
2. so we should disable this setting. Here is official guide, Android Studio/User Guide/build-cache(link https://developer.android.com/studio/build/build-cache.html).
3. go to gradle.properties file, and disable build cache.
// To re-enable the build cache, either delete the following
// line or set the property to 'true'.
android.enableBuildCache=false
the other way is to modify build cache dir by adding
# first line can be skipped because true is the default value by 2.3
android.enableBuildCache=true
android.buildCacheDir =c:\\temp\\

It's causing this error because in your drawable you must have change the extension to .png from other format.I would recommend that to change the extension use MS paint or Other image editing application like Gimp.

Related

Failed to transform file '45907c80e09917e1b776adf038505958' to match attributes {artifactType=jar} using transform AarTransform

I am using Android 3.0 canary 4 and making an app. Everything was working fine until yesterday, but today when i opened the project, it gave me an error
F:\test projects\SellIT\app\build.gradle
Error:Failed to resolve: Failed to transform file '45907c80e09917e1b776adf038505958' to match attributes {artifactType=jar} using transform AarTransform
Open File
Error:Failed to resolve: Failed to transform file '0424053f6b3433893454e7542cca3a9d' to match attributes {artifactType=jar} using transform AarTransform
Open File
Error:Failed to resolve: Failed to transform file 'customtabs-25.0.0.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
Open File
Error:Failed to resolve: Failed to transform file 'recyclerview-v7-25.4.0.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
Open File
Error:Failed to resolve: Failed to transform file 'b7ae5d97f624a2ac68ed171c25f74f21' to match attributes {artifactType=jar} using transform AarTransform
Open File
Error:Failed to resolve: Failed to transform file 'firebase-analytics-impl-10.2.4.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
Open File
Error:Failed to resolve: Failed to transform file '8a727da2aab64813ae6d20842b03d41f' to match attributes {artifactType=jar} using transform AarTransform
Open File
Error:Failed to resolve: Failed to transform file 'support-compat-25.4.0.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
Open File
Error:Failed to resolve: Failed to transform file 'd0da7bf76907aa33e493551504efa952' to match attributes {artifactType=jar} using transform AarTransform
Open File
this is my build.gradle (app level)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "android.sellit"
minSdkVersion 16
targetSdkVersion 25
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'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:25.4.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:10.2.4'
// Required only if Facebook login support is required
implementation('com.facebook.android:facebook-android-sdk:4.22.1')
implementation 'com.google.firebase:firebase-core:10.2.4'
implementation 'com.google.firebase:firebase-database:10.2.4'
implementation 'com.google.android.gms:play-services-auth:10.2.4'
implementation 'com.android.support:design:25.4.0'
implementation 'com.github.bumptech.glide:glide:4.0.0-RC1'
implementation 'com.google.firebase:firebase-storage:10.2.4'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.google.firebase:firebase-crash:10.2.4'
implementation 'com.google.firebase:firebase-ads:10.2.4'
}
apply plugin: 'com.google.gms.google-services'
Has anyone encountered a similar error or he knows what can I do?
It turns out that this is a weird bug in the Gradle itself. I posted it on google forum and one of their coders gave me a solution and also put it up as an issue with the gradle team.
For the solution, you can clear your project cache (C:\Users\<username>\.gradle\caches\transforms-1 ) and rebuild your project again and it will work fine. The gradle needs some artifacts to build which are stored in the cache memory. So if the gradle fails to build, the cache can be cleared which will prompt fresh downloading. You can be offline as long as all the artifacts you need have been downloaded in Gradle's cache (so don't delete the cache folder when offline!)
Faced the same issue. The simple way to solve this is to switch between your build variants. This refreshes the cached copies and resolves the issue.
The error seems to be caused by corrupt Jetified files.
Delete ONLY the corrupted .jars from the error message from the Gradle caches folder:
rm ~/.gradle/caches/modules-2/files-2.1/path-to/some-release.aar
The "path-to" will be probably be the package name e.g., com.example.somerelease
Usually I get the path of the file to delete from the error message itself and cut and paste it into the terminal in order to execute the rm command.
Deleting the entire folder is not an optimal solution as all the dependencies will need to be Jetified again. If you're already having corruption issues, you're likely to encounter the issue again as there is more work for Jetify when it has to reprocess the entire folder
Received similar error:
Failed to transform file 'uat-release.jar' to match attributes {artifactType=android-classes}
Transform output file D:\R\project\uat-release.jar does not exist.
In my case, Actual file was aar and bymistake I put .jar in build.gradle(of uat-release module)
configurations.maybeCreate("default")
artifacts.add("default", file('uat-release.jar'))
Solved it by correcting file type:
configurations.maybeCreate("default")
artifacts.add("default", file('uat-release.aar'))
go to destination :
Android\sdk\platforms\android-30\android.jar.
and delete what inside android-jar and rebuild project and sync
worked for me .

Android studio default project fails: Error:Failed to resolve: com.android.support:support-v4:25.2.0

I am literally just starting app development for the first time and the default project when I create a new one will not build. I have tried looking on Google and SO for these errors and have found some but their solutions do not work. Given that I have not edited the files at all, I presume it is an issue with Android Studio not being setup properly but can't figure it out. The errors are as follows:
Error:Failed to resolve: com.android.support:support-v4:25.2.0
Install Repository and sync project
Open File
Show in Project Structure dialog
Error:(23, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Install Repository and sync project
Show in File
Show in Project Structure dialog
Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.+
Install Repository and sync project
Show in File
Show in Project Structure dialog
The build.gradle file it points to is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.extremecomputing.spotzz"
minSdkVersion 17
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 {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.google.android.gms:play-services-maps:11.0.1'
testCompile 'junit:junit:4.12'
}
I have tried with a previous project that I had created a few things I found online. Such as they had recommended the + in the version could cause unpredictable builds, but that wasn't it. One had recommended a few compile lines in the dependencies section, it changed the errors for a moment saying I needed to download something, I did then it went back to the original errors. I also have tried to make sure that the SDK tools are updated, and they appear to be. Any suggestions would be greatly appreciated.
Please be noted that support library from revision 25.4.0 to the latest, we need to add google maven. As in the release note says:
Important: The support libraries are now available through Google's
Maven repository. You do not need to download the support repository
from the SDK Manager. For more information, see Support Library Setup.
So you need to add the google maven to your root build.gradle like this:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Read more at Support Library Setup.
Try this:
in Android Studio, open Tools -> Android -> SDK Manager
under tab "SDK Tools" un-check the libraries causing problems
click "apply" to uninstall them
re-check the same libraries click "apply" to reinstall them
close SDK Manager and run Gradle sync / build
I had the same problem and it was due of an interference with another library.
In my case I had to comment:
compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)
Now it builds

Could not resolve com.android.tools.build:gradle:2.2.3

I'm working on a mobile app project for work, but often when I attempt to run the application it gives me the following error:
Error:A problem occurred configuring root project 'projectName'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:2.2.3.
Required by:
:projectName:unspecified
No cached version of com.android.tools.build:gradle:2.2.3 available for offline mode.
I have tried a number of different things including deselecting the Offline work checkbox in the settings and then closing and re-opening Android Studio, but nothing seems to fix the issue. It may build fine for a few times in a row, but that same error keeps popping up. Then I have to try variations of building and making the app, or exiting and re-opening Android Studios. Nothing consistently works though. Any insight into what may be causing this issue and how it can be fixed would be appreciated.
***Update: Upon request I have added below my app gradle content
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
useLibrary 'org.apache.http.legacy'
dexOptions {
javaMaxHeapSize "8g"
}
defaultConfig {
applicationId "com.example"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
debuggable true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile files('libs/gson-2.2.2.jar')
compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.loopj.android:android-async-http:1.4.9'
}
It turns out the solution to my particular issue was relatively simple. The error message was a bit deceiving as this was not a problem with the offline mode switch, but rather confusion with the gradle file. Here are a few steps I took to fix the issue:
For Android Studio 2.3 go to File>Settings>Gradle and select the "Use default gradle wrapper" option. Also make sure the checkbox next to "Offline work" is unchecked just in case.
Click the "Apply" button
Within the build.gradle file (the one named after your project) under the "Gradle Scripts" section of Android Studio make certain that your current build gradle class path matches the current version of Android Studio. An example for Android Studio 2.3:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
Also within the Gradle Scripts section make sure that your gradle-wrapper.properties file is referencing the correct gradle file in the distribution URL. For example for gradle 3.3:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Navigate to C:\Program Files\Android\Android Studio\gradle and ensure there is a gradle folder with the same name as the gradle you are using. In my case I ensured there is a folder named gradle-3.3 with a zip file named gradle-3.3-all.zip. It is relatively easy to find this zip file online.
Delete the .gradle folder in C:\Users\yourUser with yourUser being whichever user your Android Studio project is under.
Close Android Studio and restart. It should begin the gradle sync process and rebuild the .gradle file.
For me when I did this it also complained about not finding the gradle-3.3-all.zip file in the .gradle folder. I was able to fix this by adding the gradle-3.3-all.zip file to C:\Users\yourUser.gradle\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9. I'm not sure if the folder has the same name for everyone, but whatever the name, that is the location I went to. If all this doesn't work I would try a variation of these steps, and hopefully it works for you.
The reason why it is failing is because it could not compile one of the libraries you included. Perhaps, try removing the one you suspect and try again. But most of the times, a rebuild of the project should resolve dependencies.
I've had the same pb, managed to resolve it adding in gradle.properties
systemProp.https.proxyHost=<my proxy hostname>
systemProp.https.proxyPort=<my proxy port>
I was missing HTTPS property, there was only HTTP setted so it was working sometimes, and not for the https links gradle used.

Error:Execution failed for task ':app:transformClassesWithDexForDebug' in android studio

I am moving my projects from eclipse to Android Studio. While running one of my app I get the following error. Not able to find any solution. I have enabled multidex as well.
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
also my gradle file is below
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 9
targetSdkVersion 21
multiDexEnabled true
}buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-support-v7-cardview.jar')
compile files('libs/android-support-v7-recyclerview.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.api-client:google-api-client-appengine:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client-appengine:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client-appengine:1.18.0-rc'
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-api-client-java6-1.18.0-rc.jar')
compile files('libs/google-api-client-servlet-1.18.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-http-client-jdo-1.18.0-rc.jar')
compile files('libs/google-oauth-client-java6-1.18.0-rc.jar')
compile files('libs/google-oauth-client-jetty-1.18.0-rc.jar')
compile files('libs/google-oauth-client-servlet-1.18.0-rc.jar')
compile files('libs/GraphView-4.0.1.jar')
compile files('libs/httpclient-4.0.1.jar')
compile files('libs/httpcore-4.0.1.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jetty-6.1.26.jar')
compile files('libs/jetty-util-6.1.26.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/jxl.jar')
compile files('libs/mail.jar')
compile files('libs/transaction-api-1.1.jar')
}
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException:
java.lang.RuntimeException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with
non-zero exit value 1
The upper error occure due to lot of reason. So I can put why this error occure and how to solve it.
REASON 1 : Duplicate of class file name
SOLUTION :
when your refactoring of some of your class files to a library project. and that time you write name of class file So, double check that you do not have any duplicate names
REASON 2 : When you have lot of cache Memory
SOLUTION :
Sometime if you have lot of cache memory then this error occure so solve it.
go to File/Invalidate caches / Restart then select Invalidate and Restart it will clean your cache memory.
REASON 3 : When there is internal bug or used beta Version to Switch back to stable version.
SOLUTION :
Solution is just simple go to Build menu and click Clean Project and after cleaning click Rebuild Project.
REASON 4 : When you memory of the system Configuration is low.
SOLUTION :
open Task Manager and stop the other application which are not most used at that time so it will free the space and solve OutOfMemory.
REASON 5 : The problem is your method count has exceed from 65K.
SOLUTION :
open your Project build.gradle file add
defaultConfig {
...
multiDexEnabled true
}
and in dependencies add below line.
dependencies
{
compile 'com.android.support:multidex:1.0.0'
}
**In my case problem solved with Instant Run DISABLE **
Check Whether multidex enabled or not in your build.gradle(app level) under dependencies.if not place like below
dependecies{
multidexEnabled true
}
Check your gradle.properties(app level).if you see the below code
#org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
remove # before the line ,then it should be like this
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Please
Add this into your gradle file
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
AND also add the below dependency in your gradle
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
OR another option would be: In your manifest file add the MultiDexApplication package from the multidex support library in the application tag.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
This can be because of following reason:
one of the jar files inside project was using an older version of google play services.
use multiDexEnabled true in defaultconfig
Be specific with classes you add in dependencies. like
compile 'com.google.android.gms:play-services-maps:8.4.0'
Not like compile 'com.google.android.gms:play-services:+'
I tried everything but still this error won't go, until I changed my JDK version.
My JDK version was 7, and after I changed it to 8, the error went away, you can try it if nothing else works.
i have tried this one and it worked for me.
hope it works for others too.
Open build.gradle module file
downgrade you sdkversion from 25 to 24 or 23
add 'multiDexEnabled true'
comment this line : compile 'com.android.support:appcompat-v7:25.1.0' (if it's in 'dependencies')
Sync your project
and ready to go.
Here i have attached screenshot to explain things.
Go through this steps
happy to help.
thanks.
Or you can try this -
Extend your Application class with MultiDexApplication instead of Application !
Duplicate name Classes
like
class BackGroundTask extends AsyncTask<String, Void, Void> {
and
class BackgroundTask extends AsyncTask<String, Void, Void> {
i have tried this one for more projects and it worked for me. note that solution can configure your app for multidex:
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
...
minSdkVersion 9
targetSdkVersion 25
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}}
dependencies {
compile 'com.android.support:support-v4:25.1.0'
compile 'com.google.android.gms:play-services:8.3.0'
...
}
Thank #Ironman for his complete answer, however I should add my solution according to what I've experienced facing this issue.
In build.gradle (Module: app):
compile 'com.android.support:multidex:1.0.1'
...
dexOptions {
javaMaxHeapSize "4g"
}
...
defaultConfig {
multiDexEnabled true
}
Also, put the following in gradle.properties file:
org.gradle.jvmargs=-Xmx4096m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
I should mention, these numbers are for my laptop config (MacBook Pro with 16 GB RAM) therefore please edit them as your config.
A temporary solution is to place the code below in the module build.gradle :
android {
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
And Sync the Project.
My Settings Screenshot:
Thanks to this post.
Just turn off instant run in your settings. You can easily search the keyword "instant" like I showed and it would switch to the window you want.
In my case I had 2 projects A and B. And I upgraded to gradle 4.5.
A was dependent on B but both had references of my 3rd party jar
I was getting this error
com.android.tools.r8.errors.CompilationError: Program type already
present: com.mnox.webservice.globals.WebServiceLightErrorHashCode
Program type already present: com.mnox.webservice.globals.WebServiceLightErrorHashCode
To fix it
I removed the duplicate jar's
I used api in the B build.gradle file so that it gets referred to in A.
The other root cause can be if you have upgraded to gradle 4.5 and used implementation instead of api in your commons build.gradle
Just worth mentioning that while others suggest tempering with files, I was able to resolve this issue by installing a missing plugin (ionic framework)
Hopefully it helps someone.
cordova plugin add cordova-support-google-services --save
For me the solution was to delete the gradle cache folder (.gradle/caches) in the home directory and build again. Possibly due to a duplicate class loading issue.
For Ionic 4 Just
$ cordova clean
Helped me then run
$ ionic cordova run android --device

some strange android error

https://github.com/mustafaakin/image-matcher
I imported this project using AndroidStudio's "Import Eclipse Studio Project". Edited .properties 'OpenCV - x.x.x' to 'opencv'. This is the error:
/home/uttaran/Downloads/h1/h/src/main/res/layout/main_layout.xml
Error:(62) No resource identifier found for attribute 'camera_id' in package 'in.mustafaak.imagematcher'
Error:(62) No resource identifier found for attribute 'show_fps' in package 'in.mustafaak.imagematcher'
Error:Execution failed for task ':h:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/uttaran/Android/Sdk/build-tools/23.0.3/aapt'' finished with non-zero exit value 1
Information:BUILD FAILED
As Daniel K already stated correctly:
To important an Android Application/Library in Android Studio, the project you want to import needs a build.gradle or pom.xml file in the root of the project so that the build system (Gradle/Maven) that comes with Android Studio can resolve dependencies etc. during the project import...
The Github project you refering too is this?
https://github.com/mustafaakin/image-matcher
Apparently it got written with the Eclipse IDE...and pushed to Github without any build file...
You can import it anyway, by manually creating a build.gradle file in the project root and then try to import the application again.
A possible working build.gradle file (depends on your Android Studio's Gradle plugin Version etc. I just assume now you copied your build.gradle file from a working project of yours) would be:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
}
If you did this, it probably will not find the OpenCV library dependency (red lines under OpenCV classes/methods and in imports) and you have to go in Android Studio to:
File | Project Structure | image-matcher-master | Dependencies | +
And there you add your OpenCV library as "File dependency"...if it is a JAR...otherwise if opencv in your Download folder is the source...you load this in Android Studio as well and choose "Module dependency".
If this doesn't work...this could be helpful as well:
http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html
UPDATE:
main_layout.xml contains things like:
<org.opencv.android.NativeCameraView
android:id="#+id/tutorial1_activity_native_surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="cameraclick"
android:visibility="gone"
opencv:camera_id="any"
android:layout_weight="1"
opencv:show_fps="true" />
So your OpenCV library comes with resources and views that can't be found, so you still have some problem with your src structure in your project.
This answer might be related:
Android Studio can't find opencv modules, but compiles ok
If nothing works I would recommend to import an OpenCV Android sample, check if it builds and compiles and then compare the src structure difference from your project to the sample project...
Open the Android native Camera using OpenCV

Categories

Resources