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.
Related
I recently migrated from Eclipse to Android Studio and I'm using Android Studio 1.5.1. Before when I started Android Studio, I got this error:
Failed to resolve: junit:junit:4.12
After searching in Google and trying some proposed options, only commenting junit test in app/build.gradle solved the problem:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
}
But I want to know is this a good and safe option to resolve that problem? For example does it cause any problem in future?
You will need to add the following to your build.gradle file and it should work fine.
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
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.
I am working on a simple login android application in android studio with parse. Just a few backs I switched in to studioo from ecclipse so I am not much familier with that. I am refering the following tutorial.parse tutorial
I have done everything as they mentioned. Added parse.jar[add in to libs folder and settings file updated ] and update app gradile file.
But when I tried to run the application , it crashes.java.lang.NoClassDefFoundError: com.parse.ParseUser.
If anybody have any idea about my issue please help me to solve it. I didn't find any similar questions thats why posting.
My app gradile file have below lines.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
} and we can't add dependencies to outer [main] gradile file..right?...there is
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Have you added a compile command to your build.gradle file?
For example:
compile fileTree(dir: 'libs', include: ['*.jar'])
I've created an Android library with Studio and this library needs some 3rd libraries. The build.gradle looks like below:
dependencies {
compile fileTree(dir: 'libs', include: ['*.*'])
compile 'some library:1.3.2'
compile 'some other library:1.3.4'
}
The library can be compiled freely and finely, and then I push them in to local Maven. Everything fine!
Now I create a client application just for a sample of my library. What confusion is that I must do follow:
dependencies {
compile fileTree(dir: 'libs', include: ['*.*'])
compile 'mylibrary:1.0'
compile 'some library:1.3.2'
compile 'some other library:1.3.4'
}
Which means to include the two 3rd libraries. Otherwise I must get errors "NoClassFound" which relevant to the two libraries.
You know the
compile 'mylibrary:1.0'
is the meaning to include my library, but why should I include the other twos which were used by "mylibrary"? Could I avoid that and just -compile 'mylibrary:1.0' ?
OK, I've solved project with the help of #CommonsWare
Check out
http://www.gradle.org/docs/current/userguide/publishing_maven.html
http://maven.apache.org/pom.html
To make a pom.xml self and done.
I am having this issue and seem can't figure it out when building gradle android with proguard:
Can't read [C:\Users\xxx\dev\xyz\Xyz-nextgen\build\exploded-bundles\XyzCommonXyz_volleyUnspecified.aar\libs\android-support-v13.jar(;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [android/support/a/a/b.class == android-support-v13.jar:android/support/v13/app/FragmentCompat$FragmentCompatImpl.class])
There are 3 library projects and one app project.
All projects use only one android-support-v13.jar.
Thanks.
Andy
Open the module's gradle.build file and
In
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/android-async-http-1.3.1.jar')
compile fileTree(dir: 'libs', include: '*.jar')
}
Change
compile 'com.android.support:support-v4:13.0.+'
To
compile 'com.android.support:support-v4:21.+'
make sure u have updated build tools in the sdk manager and let us know if that works