Hello I am new to android studio. I have a existing eclipse project, which runs on (2.3.3 android api 10) only.
When I migrate my existing eclipse project to android studio. I face below error.
Error:Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'.
Possible causes for this unexpected error include:
You are using JDK version 'java version "1.7.0_75"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.
Please update to a newer version (e.g. 1.7.0_67).
Open JDK Settings
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Here is my build.gradle file.
apply plugin: 'android'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
}
android {
compileSdkVersion 10
buildToolsVersion "10"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
minSdkVersion 8
targetSdkVersion 10
}
}
Can anyone help me. Thanks in advance.
I solved the problem.
I just have to change my buildToolsVersion.
From
buildToolsVersion "10"
to
buildToolsVersion "19.1.0"
Now its works perfectly.
Thanks,
please ensure your sdk is newer than jdk1.7.0_67.
open your android studio preferences page for check.
Related
I'm having a lot of trouble moving source code from github to Android Studio and I think a big part of the problem is with the gradle build tool files. I have never worked with android studio before and don't have a whole lot of coding experience in general. The gradle sync error I'm getting right now is
Error:(57,0) Plugin with id 'com.android.library' not found.
I feel like part of the problem might be the way in which i added the actionbarsherlock library. I had to add a lot of folders and so my pathways might be causing problems. Is that a possibility? I can include screenshots if that may be more helpful.
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':library')
}
android {
compileSdkVersion 19
buildToolsVersion "25.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildTypes {
debug{
debuggable = true
}
}
}
Hello i build an android app using gradle in eclipse. I allways build the project in command line using gradle. Now i try to build and run it in eclipse on android device emulator. In eclipse i don't know how can i build the project with gradle an run it on android emulator device. Please i need help.
You can find my buil.gradle file bellow
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':appcompat_v7')
compile "org.igniterealtime.smack:smack-android:4.1.0-rc1"
compile "org.igniterealtime.smack:smack-tcp:4.1.0-rc1"
// optional features
compile "org.igniterealtime.smack:smack-android-extensions:4.1.0-rc1"
}
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
mavenCentral()
}
android {
lintOptions{
abortOnError false
}
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Did you try adding the gradle eclipse plug-in
apply plugin: "eclipse"
And then generate the eclipse project from build.gradle by calling
gradle eclipse
You also should install the "Gradle IDE Pack" from the eclipse marketplace (Help -> Eclipse Marketplace...).
This question has been asked before, however, I have followed the directions carefully and am still receiving this issue. I need some help with figuring out what I am missing with my particular situation. Here is what I have done.
1) Add android-support-multidex.jar: Added android-support-multidex.jar to projected libs folder
2) Edit project build.gradle: I modified my build.gradle file located in my project's folder.
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
.....
compile 'com.android.support:multidex:1.0.0'
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.mypackagename"
minSdkVersion 14
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
3) Modify Project Application class: I have a class that extends Application. I added the following to it.
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
This was originally an Eclipse project. I exported the Eclipse project, and then imported the build.gradle file in Android Studio. I have not been able to successfully run the project since. Any help with steps I have missed would be appreciated. Thanks in advance!
Edit: Here is the contents of my top-level build file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
Replace:
classpath 'com.android.tools.build:gradle:0.12.+'
with:
classpath 'com.android.tools.build:gradle:1.0.0'
as multidex support was not offered in that 7-month-old beta release of the Gradle for Android plugin.
I'm just migrated from Eclipse. My project keeps the old structure like below
projRoot\
src\
res\
...
AndroidManifest.xml
tests
build.gradle
Here's content of build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
androidTest.setRoot('tests/src')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
testApplicationId 'com.xxx.yyy.test'
testInstrumentationRunner 'android.test.InstrumentationTestRunner'
testHandleProfiling true
testFunctionalTest true
}
}
I'm on Android Studio 0.8 beta, Gradle 1.12, I tried every possible solution found all over SO and google without any success.
Anyone can help out? Thanks.
In addition, where can I know the current version of Android Gradle plugin?
For test source set structure, follow this link. It is mentioned that test source sets should be setup as follows:
for local unit tests: module-name/src/test/java/
for android instrumentation tests: module-name/src/androidTest/java/
In case it's still doesn't work. Android Studio may encounter sometimes issues with the recognition of the tests. And the workaround would be to run local tests by using the command line:
./gradlew testVariantNameUnitTest
Once the command is run. You can go back to Android Studio and run the tests and it should work. You can find more on running tests using command line on this link.
Hope this helps.
I have an Android project which was created in Eclipse, exported as Gradle build file, then opened in Android Studio. (Yes, it would be far easier to create a clean project in AS but I need to support the current project structure.)
Otherwise things are now mostly working, but there's still some stuff to be ironed out.
In every Activity class, AS shows this error: Class requires API level 1 (current min is -1): Activity
Alt+Enter offers to fix that with a #TargetApi annotation... but why should I have to do that, when in AndroidManifest.xml, we have:
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
AndroidManifest.xml is located at project root (Eclipse default?). Looks like Android Studio is not correctly reading the settings in it. The project still compiles fine though.
Any idea how to get rid of the error?
The Eclipse-generated build.gradle looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Try to add to the build.gradle following lines right after buildToolsVersion:
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}