Android studio broke up my build.gradle file after add a Fragment - android

Using Android Studio 2.0 over El Capitan like the next screenshot said:
I found a bug that I can't report:
After add a Fragment to my project, AS screw up my module build.gradle file. I mean, before add the fragment they file looks like this screenshot:
but after add the Fragment AS screw it in this way:
The way to reproduce it is like I'm showing in next screenshot:
I can fix it manually, but its so annoying doing it every single time that I add a Fragment. Is there anyway to fix it?
I'm on Mac OX with El Capitan.

It is a still open bug, you can monitor it's state here
The bug is due to the comments in the dependencies section, a temporal fix could be to remove them from there. I placed the comments there for a reason too :)

Delete all comments in your gradle file

put your constraint-layout on the bottom, it will not scramble again (i don't know why, but it works)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// support lib
compile "com.android.support:appcompat-v7:$supportlib_version"
// kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
// ...
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}

just reformat your project level gradle . It will work fine. These compile statement got dis-formatted. Just hit Enter before every "compile"
it should be like:
compile 'com.android.support:support-v13:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.4.0'

Related

Error while merging dex archives when using map_view with flutter android

So I had been searching forever for the solution to this and what my possible problem could be. I had narrowed down the source of the issue to the map_view plugin. It kept giving me errors with the dex file merge. I eventually found the following flutter issue report:
https://github.com/flutter/flutter/issues/12945
In one of the comments it says to go into the ExternalLibraries>firebase_auth>android>build.gradle and change the dependencies from:
dependencies {
compile 'com.google.firebase:firebase-core:11.0.+'
compile 'com.google.firebase:firebase-auth:11.0.+'
compile 'com.google.firebase:firebase-database:11.0.+'
}
to:
dependencies {
compile 'com.google.firebase:firebase-core:11.+'
compile 'com.google.firebase:firebase-auth:11.+'
compile 'com.google.firebase:firebase-database:11.+'
}
and to do that for some other gradle files as well... This solution actually cause my app to break when I had map_view removed.
Later I discovered that the dependencies in map_view build.gradle file looked like the following:
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4-2'
compile 'com.google.android.gms:play-services-maps:11.+'
}
I changed it to:
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.4-2'
compile 'com.google.android.gms:play-services-maps:11.0.+'
}
Now it finally works.
Here is an image of the location of the dependency to change:
Screenshot
I hope this helps someone. Also, if there is anyone that could explain why this fixed the issue, I would greatly appreciate it!
Thanks

Android Unable to execute dex error after cloning correct project

This is a really strange problem and I've been days stuck with it: we've got a working project (no errors whatsoever) in a git repository. Everything is OK (it's even published in Google Play) when executing the project from the creator's equip, but, when we try to clone it in a different equip (we've tried Mac, Linux and Windows), this exception is thrown:
Unable to execute dex: method ID not in [0, 0xffff]: 65536
Hereafter, even if we apply the multidex solution as described in Android Developers or delete the unused dependencies, the app raises an exception when trying to load class android.support.design.widget.NavigationView (coming from a NoClassDefFound in runtime).
I suspect maybe it has something to do with the gradle plugin or appcompat libs version, but so far, nothing we've tried has worked.
Edit: This is not a common multiDex error, I'm pretty familiarized about how to solve them, it's about one computer executing the app without problems but when you clone the same project from git in other computer, it won't run and the MultiDex error is thrown.
EDIT 2: mi dependenvy list is as follows (I ommit the company libs but they're not the problem
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.mo2o.third:valnif:1.0.0'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile('com.afollestad.material-dialogs:core:0.8.0.1#aar') {
transitive = true
}
compile 'com.android.support:percent:23.0.0'
compile 'se.emilsjolander:stickylistheaders:2.6.0'
compile 'me.grantland:autofittextview:0.2.+'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile "com.google.android.gms:play-services-gcm:8.3.0"
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'

I have trouble configure android studio header file

I have the driver install, but i do not see what the problem is.
Problem is in your gradle file
make sure you added this dependencies
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.google.android.gms:play-services-location:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'

Gradle Build Speeds

I created a new project in Android Studio yesterday, after creating it with just one blank activity it consistently too in excess of 14 Minutes to build. Looking at a previous project that has multiple activities that compiles in less than 4 Seconds I noticed the following differences in my build.gradle file
Fast Compile(4 Seconds) has the following
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
Slow Compile (>14 Minutes) has the following
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
}
I changed the new project to use the dependencies from the old project and surprise it to built in less than 4 seconds.
What is going on here? Am I doing something wrong, missing something obvious?
Thanks in advance.
When you compile project, it checks dependencies and download if! required. Thats whould be the reason why it took. Since downloading operation is executed once, next builds will be more speedy.
On the other hand if you did download operation before (which is previous project), gradle can use from local disk. It makes it faster.

Why my app is errors when I just create it?

I use android studio with sdk v24.
When I create my new application and just go to the MainActivity.jar It shows me many codes red?
Here it is that I'm talking about:(screen shot)
https://dl.dropboxusercontent.com/u/100174344/Screenshot%202015-01-06%2008.06.09.png
I'm really confused. How can I fix these errors?
NOTE: my sdk is up to date (as you see here: https://dl.dropboxusercontent.com/u/100174344/Screenshot%202015-01-06%2008.22.28.png )
and I've added this code to my build.gradle(Module: app) :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3' }
EDIT:
I'm sorry I create a new project and still it show me the codes, red but I can run it in AVD. what's the problem?
You want To add android.support.v7.jar not added that y i think this error occurs.
add this in your project property file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.+'
}
Did you added android.support.v7.jar? Just make sure your sdk is updated and you've added android.support.v7.jar. Also check the dependencies.
You need to add appcompat v7 dependencies to the app gradle file.
Ensure build.gradle(Module : app) is having the dependency.
If not available then add and sync the project
It should be like-
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.+'
}
I found the problem
I don't know why but when I changed the theme by this structure the issue is up.

Categories

Resources